A server connection
timeout error does little to tell you what went wrong or why the error
happened: it just identifies that the error occurred. Since Endpoints send the message out,
they can encounter various transport errors. For example connection may time
out, or connection may be closed by the actual service and even an Internet connection can be at
fault.
Today we are talking how we can deal with Connection timed out
errors in APIM.
Use-Case
Suppose a user
is having a backend which is taking more than 5 -6 minutes to give a response
back, The API that is waiting for backend response and will make timeout error after
waiting 30000ms since exceeding of default value of the endpoint timeout by
thinking connection may be closed by the actual service.
We can get over with
this kind of situations by doing manual configurations inside the apim
configurations.
There are 3 types of timeouts in API Manager
- Endpoint timeout/connection timeout in per API level
- Socket timeout
- Global timeout
- When it’s needed to Set timeout in API level per each API you can go for following method. You can set the timeout value through management console for the API you want to increase the time out for 6 min.(60000miliseconds * 6 = 360000 ms)Please note that this configuration will override the "synapse.global_timeout_interval" value for that API
- Socket timeout defined in the passthru-http.properties (APIMHOME\repository\conf\passthru-http.properties)
<api name="admin--Emailverification" context="/phoneverify" version="1.0.0" version-type="url"> <send> <endpoint name="admin--Emailverification_APIproductionEndpoint_0"> <http uri-template=" http://ws.cdyne.com/emailverify/emailverify.asmx" /> <timeout> <duration> 360000 </duration> <responseAction>fault</responseAction> </timeout> </endpoint> </send> </api>
http.socket.timeout=60000000
- But According to the scenario we are talking here you can see endpoint timeout > http.socket.timeout since our default socket.timeout is 60000ms ..
- It's important If the endpoint timeout > http.socket.timeout, whatever value we set in endpoint timeout is not getting applied, but the value of http.socket.timeout will be used in request timeouts. Basically, when endpoint timeout > http.socket.timeout, the engine will timeout the endpoint after http.socket.timeout, irrespective of the timeout action or timeout value we configured in endpoint level.
- So it is a must to configure http.socket timeout to higher value than the synapse global timeout or endpoint timeout values.
So I am increasing the socket timeout value here, adhering to the above condition ("http.socket.timeout=60000000" )
synapse.global_timeout_interval=60000000
Note:
If you need any further assistance or have queries regarding the "WSO2 API Manager : Configure timeouts" Do not hesitate to comment below ....