Skip to content

http_client does not gracefully handle remotely-closed keepalive connections (Linux/ASIO) #592

Closed
@Olipro

Description

From my discussion with Robert, the issue manifests itself like so:

  1. Have a keepalive socket as an http_client to some server.
  2. Server sends a FIN ACK as it decides the connection has been idle for too long which puts the socket into CLOSE_WAIT
  3. 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.
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions