-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Unexpected SSLEOFError
when Receiving Redirect (307) Response with Large Data Payload
#6885
Comments
Hi, wanted to add some background for this issue. We noticed this on only Python versions 3.10-3.12. See these related issues:
Below is a screenshot of a pcap file for our specific SDK/server interaction. You can see the client receive a RST without sending a prior FIN packet. This seems to be some problem in handling the close_notify message from RFC-5246-7.2.1 In testing I observed this only happened with our Python SDK -- our similar GO SDK sends a FIN before following the redirect from the same server. We implemented a workaround here: NVIDIA/aistore@06c0881 This strips the data from the request to our proxy service and opens a new session for the request with data to the target. This works, but I believe is less than optimal since we have to create a new requests session. |
Why do you believe you have to create a new session? |
I was actually wondering that myself looking back at it 😆. I may have left it from a previous attempt at a workaround. Testing it out, that part seems to not actually be necessary unless I'm missing something. Still, the fix of stripping out the data and manually parsing the redirect should probably not be necessary. |
This issue occurs only when TLS is enabled on both the client and server sides.
When a
requests
client sends a largePUT
request and receives an HTTP 307 redirect, the server may close the connection early before the payload is fully transmitted. This happens because the server issuing the redirect does not need to process the request body, so it terminates the connection as soon as it sends the redirect response. However,requests
does not handle this scenario gracefully and raises the following SSL error:Expected Result
If an HTTP 307 redirect is received before the payload is fully transmitted,
requests
should handle the redirect properly without complaining on the previous early-closed connection. The client should not fail simply because the server closed the connection early.Actual Result
requests
fails withSSLEOFError
instead of retrying the request to the redirected location.This issue does not occur with small payloads (maybe because they are typically sent in a single transmission chunk and completes before the server closes it?)
Reproduction Steps
Client-Side Code
Server-Side Code (Minimal Proxy)
SSL Certificate Generation
If needed, generate self-signed TLS certificates using the following OpenSSL commands:
System Information
Python 3.10.12 (main, Jan 17 2025, 14:35:34) [GCC 11.4.0] on linux
$ python3 -m requests.help
The text was updated successfully, but these errors were encountered: