Hi,

I am encountering a problem with http 1.1 clients that reuse their connection 
just at the same moment that HAProxy is closing it, resulting in socket hangup 
ECONNRESET style errors. Version is 1.9.4.

In our haproxy config we have something like :

    timeout http-keep-alive 5s

A client who: opens a connection, does a number of requests, then idles for 5 
seconds before firing off another requests will sometimes encounter an error. 
The server is close the socket while the client is sending the last request. 
The client must retry/handle the error gracefully.

We can avoid the problem by setting a similar timeout client side so that they 
do not try to reuse a connection that has been idle for say, 4 seconds, but 
this is difficult to manage when we cannot control all the clients.

The timeout parameter of the Keep-Alive header seems like it could help : 
https://tools.ietf.org/id/draft-thomson-hybi-http-timeout-01.html#p-timeout 

I'd almost expect HAProxy to add the Keep-Alive header when it sees Connection: 
Keep-Alive in the request, but maybe that's going too far.

Is it a good practice to do some header manipulation to communicate this 
timeout from HAProxy to the client ? I.e. :

    timeout http-keep-alive 5s
    http-response set-header Connection Keep-Alive
    http-response set-header Keep-Alive timeout=4

Having HAProxy indicate the correct timeout value would be more manageable that 
implementing it in each of our clients ...

Regards,

Robert Higgins

Reply via email to