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
Retry doesn't retry upon ConnectionResetError #2751
Comments
I found this issue while I was troubleshooting another case of non-retries requests done by Was about your case, @vitaly-krugl, did you learn anything more that you can share? |
@gdubicki - thanks for sharing your issue. And no, I have not learned anything more. |
I ran into a similar issue, using urllib3 by itself. In my experience if the remote server is down prior to making the request, then it retries as expected. However if instead the server is up prior to starting, but goes down unexpectedly in the middle of the request, then the request immediately raises a Repo script: import logging
import sys
import urllib3
from urllib3.util import Retry
print(sys.version)
print(urllib3.__version__)
#logging.basicConfig(level=logging.DEBUG)
body = '[{"a":1}]'
retries = Retry(total=10,
backoff_factor=0.1,
respect_retry_after_header=True,
status_forcelist=[429, 500, 502, 503, 504])
http = urllib3.PoolManager(retries=retries)
while True:
resp = http.request("POST",
"http://127.0.0.1:8080/test",
headers={"Content-Type": "application/json"},
timeout=30,
body=body) Output:
|
Hello, I do confirm the behavior and the issue: when using By "does not work correctly", i mean that:
Here is a simple script to reproduce the issue import urllib3
from urllib3.util.retry import Retry
http = urllib3.PoolManager(retries=Retry(total=None, backoff_factor=1))
# This is raising an error (but it shoudn't)
resp = http.request("GET", "http://localhost:5000", preload_content=False)
for chunk in resp.stream(32):
print(chunk)
# However, this is working correctly (no error)
#resp = http.request("GET", "http://localhost:5000") This reproduction script needs to make a query to an intentionally broken web server from flask import Flask, make_response
app = Flask(__name__)
@app.route('/')
# generate an intentionally broken response.
# should trigger an IncompleteRead if no retry strategy is implemented
def send_incomplete_response():
response = make_response('fourteen chars')
response.headers['Content-Length'] = '10000'
return response
app.run() The issue is also discussed here : #542 |
Any progress on this? |
Subject
My application uses the urllib3 Retry class. When the socket connection fails with
ConnectionResetError
during ingestion of response, the Retry doesn't retry it.Environment
Python 3.9 on OS X
Steps to Reproduce
My app uses urllib3 via the requests 2.12.0 package. It appears that the connection reset occurs while
requests
is ingesting the response from the urllib3 response stream. Session and Retry are configured as follows:Expected Behavior
I expected the request to be retried automatically. Failure to do retries upon connection reset would appear to be a serious flaw in the Retry stack.
Actual Behavior
Request is not retried and fails with the following exception:
The text was updated successfully, but these errors were encountered: