http_client does not gracefully handle remotely-closed keepalive connections (Linux/ASIO) #592
Closed
Description
opened on Nov 4, 2017
From my discussion with Robert, the issue manifests itself like so:
- Have a keepalive socket as an
http_client
to some server. - Server sends a FIN ACK as it decides the connection has been idle for too long which puts the socket into CLOSE_WAIT
- something comes along and makes a new request with the
http_client
instance, headers are sent on the socket which is in CLOSE_WAIT so they are still received. - Since the server can't actually respond, the connection gets an RST from the server end and cpprestsdk finds out about it when it moves onto trying to write the body, consequently throwing an exception to the user.
Firstly, we should try other connections if we end up in this state, however, retrying all connections will result in one unlucky caller spending time acting as a garbage collector for all the dead sockets, which could be numerous.
One option for dealing with this is to retry the pool of existing connections in a limited fashion such that anyone who encounters 2 failures will give up and (try to) establish a new connection - so they'll still have cleaned up more than they created.
Metadata
Assignees
Labels
No labels
Activity