httplib2 icon indicating copy to clipboard operation
httplib2 copied to clipboard

Reading the actual request may trigger CONNRESET on a cached connection

Open smurfix opened this issue 7 years ago • 2 comments

This moves the block that reads the data up into the try: block.

I hit this issue while testing aioamqp with pyrabbit. The sequence of events is:

  • send request without auth header
  • get an error
  • … meanwhile, the server starts thinking about what you just did (like doing a DNS lookup for its error log)
  • re-send the request with auth header
  • … the server gets around to deciding that it wants to close your connection, and does so
  • get an ECONNRESET error reading the reply. :-(

This can also happen when you're re-using a cached connection after some time and hit the server's decision that it has waited long enough and will now close the connection.

Thus, please apply.

(This is a copy/rebase of https://github.com/jcgregorio/httplib2/pull/320)

smurfix avatar Jul 13 '17 10:07 smurfix

Thank you very much. Patch seems fine.

Dear users and @httplib2/maintainers is it possible to give this one a bit of field testing? To compensate automated tests.

pip install https://github.com/httplib2/httplib2/archive/b1b47957f4a3402392bd9897ca15d8566d0d614d.zip

temoto avatar Aug 16 '17 05:08 temoto

Suggest adding the connection retry for errno.ECONNABORTED.

weyou avatar Mar 16 '21 06:03 weyou