Hi all,

our application is hosted on a server in the Azure cloud and it uses Apache HTTPClient (currently version 4.5.x, but that makes no difference for problem) to communicate to an external web service that does not specify a keep-alive timeout in it's response, so the timeout it is interpreted as "indefinitely"

Unfortunately Azure (outbound load balancer? SNAT? ...?) drops the connection, maybe because it is idle, after about 4 minutes.

The isStale() method in BHttpConnectionBase performs a check of trying to read from the connection after setting the socket timeout to one millisecond. As far as I see, it is expected that this will trigger a SocketTimeoutException in the case that the connection is not stale and the socket timeout of one millisecond makes sure that this happens as fast as possible. So a catched SocketTimeoutException is seen as proof that the connection is not stale and isStale() returns false in that case.

However in the light of connections that were dropped by Azure or the like this check of trying to read and interprete a SocketTimeoutException obviously does not seem to work as any attempt to communicate to the external web service over such a connection (which is not stale according to isStale()) will lead to errors, in our case also to a SocketTimeoutException

Of course, our problem is easily solved by using a custom ConnectionKeepAliveStrategy that limits the keep-alive timeout to significantly under 4 minutes but it would be more satisfactory if there were a solution, that can determine if a connection is stale or not, even when the connection is, as in our case, dropped by some firewall, load balancer, ...

Do you have any idea if this is possible?

Thank you in advance for your answer

Regards
Matthias


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to