curl-library
RE: Keepalive
Date: Wed, 19 Mar 2008 18:08:39 +0100
> -----Original Message-----
> From: curl-library-bounces_at_cool.haxx.se
> [mailto:curl-library-bounces_at_cool.haxx.se] On Behalf Of Jamie Lokier
> Sent: Wednesday, March 19, 2008 4:47 PM
> Gabriel Kälin wrote:
> > TCP keep-alive indeed is a partial solution, but it doesn't
> solve the problem if the firewall is reconfigured or drops
> the connections anyway.
>
> TCP keep-alive should solve that problem. If a firewall drops the
> connection, TCP keep-alive will detect eventually that it's not
> getting a response, and that will be flagged as a socket error.
> Unfortunately the detection time is very long on some OSes, and
> configurable by the app only on a few.
Thank you for your explanations. But the long timeout is exactly what makes it only a partial solution in my situation. I'd like to have something like a connect-timeout of e.g. 10 seconds when I start a new HTTP request on an re-used TCP connection. But if the request could be sent successfully, I would allow the server to take minutes until it produces a HTTP response.
I'll check whether Solaris 10 offers any timeout configuration possibilities for TCP keep alive. Maybe that will work for me.
>
> > I'm not that much bothered with TCP connections in the CLOSE_WAIT
> > state, but when a new request is performed, I don't want libcurl to
> > take too long until it figures out that the connection may be dead.
>
> Unfortunately, there is no way to detect a dead connection other than
> trying it, and waiting for a response. You can reduce the likelihood
> of a long delay by only reusing connections that have been idle for
> less than N seconds, when N is less than you expect firewall timeouts
> to be. (Unfortunately I've seen firewall timeouts less than 30
> seconds in real life).
That's actually a good idea to work around the problem. This would at least reduce the risk of ending with a dead connection. The time overhead shouldn't hurt too much to establish a new connection if the old one had not been used for many seconds. I'd probably need to do that in libcurl though, as the application does not have access to the TCP connections used by curl handles, right?
Gabriel
Received on 2008-03-19