-
Notifications
You must be signed in to change notification settings - Fork 390
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
fails to re-establish a connection after keep-alive timout #468
Comments
Thank you for reporting this bug! Much appreciated. We recently released Would you be open to contributing a pull request to address this? I'd be more than happy to collaborate getting the TravisCI to pass to get it over the line. Then we can put out a fix shortly. If you haven't got the bandwidth, that's fine too. Is there a toy repo that we could clone to replicate the issue at least? |
Hey, so as you expected, 2.1.0 doesn't fix the issue. And I must admit I don't really have the bandwidth to dive into the details of VCR itself to help you fixing this. However, I sat down and made you a smaller reproducer, so that's something ;) import time
import requests
import vcr
URL = 'https://www.die-welt.net/'
with vcr.use_cassette('test.yaml', record_mode='all'):
s = requests.Session()
s.verify = False
s.get(URL)
time.sleep(10)
s.get(URL) If I am not mistaken, you can point |
Awesome! I’ll have a crack at replicating it myself with that sample. That’s really helpful thanks. |
I can confirm that this is still an issue with |
With old patching method, urllib3 never detected TCP connections that were closed by the server side. For example, persistent HTTP connection that were closed by the server (e.g., due to timeout) were not recognized as closed. Any following requests that attempted to reuse the same, closed connection caused the following failure: urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response' )) Fixes: kevin1024#468
Hello! I am also one of the unfortunate ones who has encountered this issue. Thankfully I managed to debug and fix it. See PR #605. |
vcrpy 2.0.1, requests 2.22.0
We are using requests with sessions to call an API endpoint to trigger a job and then call another endpoint in a loop to get the job status and thus wait until the job is done. The server is an Apache httpd with
KeepAliveTimeout 5
and a Rails app.The code is working fine outside of VCR, but as soon as we enable VCR recording, the "wait" part of the code fails (
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))
on Python 2.7,requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
on Python 3.7)Example code:
output:
As you can see, the server answers with
'keep-alive': 'timeout=5, max=10000'
to thePOST
, but we usetime.sleep(10)
to wait.Lowering the
sleep
to 4 (so below the timeout) avoids the problem.However, it should be the responsibility of the underlying http client to re-open the connection if needed. And
requests
does so just fine if used outside ofVCR
. Thus we think this is a bug in VCR.The text was updated successfully, but these errors were encountered: