Timeout property in ServiceCallout not throwing 500 error

I have the ff. policy which has a successful response but its response will be delayed by 30 seconds. But for some reason, the ServiceCallout policy won't throw a 500 error even though the Timeout of the API was clearly set at 20 seconds

<ServiceCallout async="false" continueOnError="true" enabled="true" name="SC-MockedResponse">
    <Response>calloutRes</Response>
    <Timeout>20000</Timeout>
    <HTTPTargetConnection>
        <!--Successful Response w/ delay-->
        <URL>https://run.mocky.io/v3/9019ba5d-6878-4ad1-a92e-1b95f2b5407a?mocky-delay=30000ms</URL>
    </HTTPTargetConnection>
</ServiceCallout>

I saw in this documentation that the policy should return a 500 error if I set the Timeout and it was triggered. But there was no 500 response whatsoever in the Service Callout, even the tracelog shows 200 response.

10162-screenshot-575.png

10164-screenshot-576.png

Its just that I am expecting an error code of 500 as I use it as a trigger on other policies, but the policy is not throwing any 500 error at all.

0 8 249
8 REPLIES 8

Not applicable

In the service callout trace you can see the delay is 56000ms. It seems the service callout is getting response in the stream, that's why not getting a timeout. Need to check the trace and try more cases to get final conclusion.

It won't be able to get the full response as the delay and supposed response time is supposed to be 30seconds. The screenshot was just outdated, but its currently at 30 seconds delay, and the Timeout is at 20 seconds, but even with 5 seconds timeout, I'm not getting any 500 error.

can you try to hit the same endpoint as an api and generate timeout error?

I could trigger the timeout error if I set the delay to 60+ seconds. But I want the API to timeout within 20 seconds in a service callout, which is not triggering the 500 error flow.

Not applicable

can you try adding this in the service callout inside <HTTPTargetConnection> tag

<Properties><Property name="io.timeout.millis">20000</Property></Properties>

I tried this and it works for me. It throws 500 internal server error.

I already have this exact code

<ServiceCallout async="false" continueOnError="true" enabled="true" name="SC-MockedBlankResponse">
    <Response>calloutRes</Response>
    <Timeout>20000</Timeout>
    <HTTPTargetConnection>
        <Properties>
            <Property name="io.timeout.millis">20000</Property>
        </Properties>
        <!--Successful Response w/ delay-->
        <URL>https://run.mocky.io/v3/9019ba5d-6878-4ad1-a92e-1b95f2b5407a?mocky-delay=30000ms</URL>
    </HTTPTargetConnection>
</ServiceCallout>

But there is no error.

10166-screenshot-584.png

10167-screenshot-585.png

But, I see error 500 in my test. Can you make the value to 1 and test