-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
#4587 Always check transport is not closing before reuse #4778
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4778 +/- ##
==========================================
- Coverage 97.60% 97.57% -0.04%
==========================================
Files 43 43
Lines 8932 8940 +8
Branches 1406 1408 +2
==========================================
+ Hits 8718 8723 +5
- Misses 95 97 +2
- Partials 119 120 +1
Continue to review full report at Codecov.
|
@Dahuage Hi, you said one can configure properly on aiohttp side to avoid the error, how can I do it? |
if the error is caused by the server you requested disable keep-alive. then config the aiohttp send http1.0 request to the server may avoid this problem. just init the session like this:
by the way, if the server you requested is under your control, make sure your server enable HTTP/1.1 keepalive connections. hope it helps! |
@Dahuage thanks for the answer. The server is not under my control, so I just enabled http1.0, looks like it works |
It's too cool! |
Thank you for your contribution to help me solve the problem for a long time. |
wow ! cool ! |
Seems that one test fail |
Any updates on this ? |
Would also be very interested in this fix! :) And thank you for the contribution! |
Codecov Report
@@ Coverage Diff @@
## master #4778 +/- ##
==========================================
- Coverage 97.58% 97.56% -0.03%
==========================================
Files 43 43
Lines 8960 8968 +8
Branches 1414 1416 +2
==========================================
+ Hits 8744 8750 +6
- Misses 97 98 +1
- Partials 119 120 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Thanks! |
💚 Backport successfulThe PR was backported to the following branches:
|
What do these changes do?
Always check transport is not closing before reuse a connection.
Reuse a protocol based on keepalive in headers is unreliable.
For example, uWSGI will not support keepalive even it serves a
http1.1 request, except explicitly configure uWSGI with a
--http-keepalive
option.Servers designed like uWSGI would cause aiohttp intermittently
raise a ConnectionResetException when the protocol poll runs
out and some protocol is reused.
Though it can be bypassed by properly configuring either in server like uWSGI or aiohttp side, this exception is confusing and annoying for new guys to aiohttp.
Yet more importantly, sometimes it can not be triggered in a development env, but it is a potential disaster when in a production env where it has high concurrence.
Are there changes in behavior for the user?
No
Related issue number
#4587
Checklist
CONTRIBUTORS.txt
CHANGES
folder<issue_id>.<type>
for example (588.bugfix)issue_id
change it to the pr id after creating the pr.feature
: Signifying a new feature..bugfix
: Signifying a bug fix..doc
: Signifying a documentation improvement..removal
: Signifying a deprecation or removal of public API..misc
: A ticket has been closed, but it is not of interest to users.