Why is io.timeout.millis property not triggering timeout even though target server takes longer time?

We have set the io.timeout.millis property in one of our API proxies to 10 seconds as shown below

<Properties>
    <Property name="response.streaming.enabled">true</Property>
    <Property name="request.streaming.enabled">true</Property>
    <Property name="io.timeout.millis">10000</Property>
    <Property name="success.codes">1xx,2xx,3xx,4xx,5xx</Property>
</Properties>

We notice that target server takes longer than 10 seconds for some of the API requests. However, we continue to get 200 Response code. Ideally we should to get a 504 Gateway Timeout.

Can you please let us know why the io.timeout.millis is not triggering timeout after 10 seconds ?

Solved Solved
1 2 2,085
1 ACCEPTED SOLUTION

I found that the cause for this behaviour is that the target server was drip feeding the response to the Edge (Message Processor). That is, the target server would send a few bytes of data after few seconds. For example: the target server is sending few bytes every 5 seconds. This causes the timer to be restarted again from 0 seconds after every 5 seconds. In this way, the timer never reaches the set timeout period (io.timeout.millis) of 10 seconds.

Hence, we don't get a timeout error (504 Gateway Timeout).

After investigating I did find an alternative solution if we really want to timeout after 10 seconds irrespective of how the target server sends the response back to Edge. That is you could use the property api.timeout as shown below:

<HTTPProxyConnection> 
   <BasePath>/v1/testapitimeout</BasePath> 
   <Properties> 
      <Property name="api.timeout">10000</Property> 
   </Properties> 
   <VirtualHost>default</VirtualHost> 
   <VirtualHost>secure</VirtualHost> 
</HTTPProxyConnection>

This worked for me in my local tests.

Please note, the following about this property:

1. This property needs to be set in the Proxy endpoint definition

2. The timeout period set using this property starts ticking in as soon as the PreFlow of Proxy endpoint starts unlike the io.timeout.millis which starts ticking in after the request has been sent to the target server.

Please read more about api.timeout property here.

View solution in original post

2 REPLIES 2

I found that the cause for this behaviour is that the target server was drip feeding the response to the Edge (Message Processor). That is, the target server would send a few bytes of data after few seconds. For example: the target server is sending few bytes every 5 seconds. This causes the timer to be restarted again from 0 seconds after every 5 seconds. In this way, the timer never reaches the set timeout period (io.timeout.millis) of 10 seconds.

Hence, we don't get a timeout error (504 Gateway Timeout).

After investigating I did find an alternative solution if we really want to timeout after 10 seconds irrespective of how the target server sends the response back to Edge. That is you could use the property api.timeout as shown below:

<HTTPProxyConnection> 
   <BasePath>/v1/testapitimeout</BasePath> 
   <Properties> 
      <Property name="api.timeout">10000</Property> 
   </Properties> 
   <VirtualHost>default</VirtualHost> 
   <VirtualHost>secure</VirtualHost> 
</HTTPProxyConnection>

This worked for me in my local tests.

Please note, the following about this property:

1. This property needs to be set in the Proxy endpoint definition

2. The timeout period set using this property starts ticking in as soon as the PreFlow of Proxy endpoint starts unlike the io.timeout.millis which starts ticking in after the request has been sent to the target server.

Please read more about api.timeout property here.

Hi AMAR DEVEGOWDA,

Thank you for the detailed explanation. Couple of questions on this

1) Would this api.timeout can force MP from waiting for same transaction which is currently on waiting?

2) Also what goes to analytics, would there be 2 entries one with api.timeout and other with io.timeout.millis wait completes?

Regards,

Remeesh