Comments (8)
Done!
from urllib3.
Can you please try reproducing using only http.client in the Python standard library?
from urllib3.
When I change this to a POST
to a different service (e.g., httpbin) rather than a GET
with a semantically meaningless body to google.com
, I see no such issue. Many services and load balancers close connections like this as a form of denial of service protection.
Furthermore, 3.10+ have different default SSLContext ciphers that the client uses/allows. So it's possible that if you want to continue your poor behaviour, you should research what ciphersuites you need and set those yourself.
This isn't a regression of behaviour in urllib3 as it's likely originating from Python's ssl
library.
from urllib3.
The example was a simple reproduction use-case. We are seeing the behavior with a simple upload system where uploading large files is expected (not poor behavior!). Also the request work fine with Python 3.9 and the regression only starts with Python 3.10.
from urllib3.
I am confirming the issue with a POST request as well. We have tested the issue on a couple dozen Linux boxes.
>>> response = http.request('POST', 'https://www.google.com/', body=data)
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 665, in urlopen
httplib_response = self._make_request(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 387, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python3.10/http/client.py", line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1077, in _send_output
self.send(chunk)
File "/usr/lib/python3.10/http/client.py", line 999, in send
self.sock.sendall(data)
File "/usr/lib/python3.10/ssl.py", line 1237, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.10/ssl.py", line 1206, in send
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request
return self.request_encode_body(
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "/usr/lib/python3/dist-packages/urllib3/poolmanager.py", line 330, in urlopen
response = conn.urlopen(method, u.request_uri, **kw)
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 747, in urlopen
return self.urlopen(
File "/usr/lib/python3/dist-packages/urllib3/connectionpool.py", line 719, in urlopen
retries = retries.increment(
File "/usr/lib/python3/dist-packages/urllib3/util/retry.py", line 436, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.google.com', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:2426)')))
from urllib3.
I do reproduce with http.client
:
>>> http.client.HTTPSConnection("www.google.com").request('POST', '/', body=b'A'*1000000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/http/client.py", line 1283, in request
self._send_request(method, url, body, headers, encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1329, in _send_request
self.endheaders(body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1278, in endheaders
self._send_output(message_body, encode_chunked=encode_chunked)
File "/usr/lib/python3.10/http/client.py", line 1077, in _send_output
self.send(chunk)
File "/usr/lib/python3.10/http/client.py", line 999, in send
self.sock.sendall(data)
File "/usr/lib/python3.10/ssl.py", line 1237, in sendall
v = self.send(byte_view[count:])
File "/usr/lib/python3.10/ssl.py", line 1206, in send
return self._sslobj.write(data)
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2426)
I had initially opened an issue with CPython, but it was closed and was redirected to urllib3
.
from urllib3.
@hugovk Would you mind reopening python/cpython#110467? 🙏
from urllib3.
Closed in favor of python/cpython#110467, thanks for the investigative work everyone!
from urllib3.
Related Issues (20)
- Add support for using HTTP/2 without TLS or prior knowledge HOT 1
- pypy tests often fail in CI with reason "cancelled after 30 minutes"
- Comply with TLS settings mandated for HTTP/2 in RFC 9113
- Upgrade mypy to the latest version in CI HOT 1
- Fix type checking when Zstandard is installed
- Move length_remaining into BaseHTTPResponse HOT 1
- Slow test cases on pypy3.9-7.3.15 on Ubuntu 22.04
- TLS 1.3 Post Handshake Auth no longer working with urllib 2.1.0 when ignoring cert validation HOT 1
- Create a workflow (nox?) for testing Emscripten support locally
- Emscripten support emits an InsecureRequestWarning even when using HTTPS
- Path toward testing with a released version of hypercorn? HOT 3
- Handle HTTP/2 informational responses (1xx) HOT 2
- urllib3 2.2 explicitly casts all headers to HTTPHeaderDict HOT 4
- Streaming responses using urllib3 HOT 5
- verbose logging output
- Excess leading path separators causes ConnectionPool.urlopen to parse URL as host & port HOT 1
- ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) HOT 1
- SSL: UNEXPECTED_EOF_WHILE_READING HOT 7
- imprecise types on `urllib3.Retry.new` / `urllib3.Retry.increment` HOT 1
- Investigate CI failures with Python 3.13.0a5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from urllib3.