1
votes

I want to specify timeout duration for a non suspend endpoint as 3000ms (3sec). I used the configuration in WSO2 documentation and configured my endpoint file as follows:

<?xml version="1.0" encoding="UTF-8"?>
<endpoint name="myEndpointFile" xmlns="http://ws.apache.org/ns/synapse">
<property expression="get-property('endpointAddress')" name="endpointAddress"/>
<address uri="${endpointAddress}">
        <timeout>
           <duration>3000</duration>
           <responseAction>fault</responseAction>
       </timeout>
       <suspendOnFailure>
           <errorCodes>-1</errorCodes>
           <initialDuration>0</initialDuration>
           <progressionFactor>1.0</progressionFactor>
           <maximumDuration>0</maximumDuration>
       </suspendOnFailure>
       <markForSuspension>
           <errorCodes>-1</errorCodes>
       </markForSuspension>
</address>

To be able to test it, I used a mocky.io endpoint that has 7000ms(7sec) response delay http://www.mocky.io/v2/5e7b12732d00008f00119be6?mocky-delay=7000ms

When I tried to call the API which calls that endpoint URL, I got still success HTTP 200 OK even if my timeout duration is 3000ms (3sec).

postman status

Here is my synapse.global_timeout_interval parameter in synapse.properties:

synapse.global_timeout_interval=200000

and also my http.socket.timeout property value in passthru-http.properties:

http.socket.timeout=180000

Version: WSO2EI6.4.0

Thanks for any idea!

Regards

1
How are you calling this endpoint? Via call mediator blocking mode? Or send mediator? Or something else? - Arunan Sugunakumar
Hi @ArunanSugunakumar, I'm calling via call mediator. - BK.

1 Answers

1
votes

Let me briefly explain the process of the timeout handler. When we invoke an endpoint the ESB register a callback and when there is a task to check if the timeout period is exceeded. When the task identifies that the call back registered exceeded the timeout period it removes the registered callback.

The timeout value you have defined is significantly small. By default the task that timeout the request runs in every 15 seconds. You can change this with the timeout_handler_interval parameter [1].

But reducing this to a significantly lower value is not recommended. Since this task is running in 15s interval, the actual timeout can happen over the range 3s (best case) to 3 +15 s (range 3s-18s).

[1]-http://sanjeewamalalgoda.blogspot.com/2016/07/how-endpoint-timeouts-and-timeout.html