Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try to resend request if connection has been closed. #1682

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blacktea
Copy link

@blacktea blacktea commented Feb 8, 2022

Hi, all!

Case:
We've got a client that sends messages to a server. I came across a problem when client failed to write request body. I found out that the reason was the connection was closed after the "keep-alive" timeout expired.
They use HTTP/1.1 and Keep-Alive connection.

Tcpdump trace:
image

155 - client, 159 - server.
At the beginning, the client sends a request and accepts a response from the server. Then, in 19 secs FIN packet is arrived. At 209.852367 we try to write headers. In response, we accepts RST packet. In cpprestsdk it means "Broken pipe" at https://github.com/microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client_asio.cpp#L1303.

My solution:
There is an attempt to restore the closed connection at https://github.com/microsoft/cpprestsdk/blob/master/Release/src/http/client/http_client_asio.cpp#L1347.
I decided to use this method to handle body write error.
I managed to reproduce the error in unit-tests.

@ghost
Copy link

ghost commented Feb 8, 2022

CLA assistant check
All CLA requirements met.

@blacktea
Copy link
Author

@barcharcraz, Could you review please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant