Open adamtheturtle opened 2 years ago
~I'm closing this as I reproduced the error with urllib
(and not urllib3
) and so this isn't the place to dig.~
I'm re-opening this as I have found what I think may be a behaviour change between Python versions that should be handled differently by urllib3
.
See this code with urllib
:
from urllib.request import Request, urlopen
# On Python 3.9 we get a "broken pipe", but on 3.10 we get an EOF occurred error.
body = b"a" * int(2 ** 21 + 1)
req = Request('https://cloudreco.vuforia.com/v1/query', data=body)
response = urlopen(req)
The broken pipe error is swallowed on purpose:
but the SSLEOFError
is not.
The PR which introduced the broken pipe error skipping: #1524
This is getting a little deep for me (RFCs) and such.
However, I put an except SSLEOFError: pass
in connectionpool.py
and ran my original sample code, and I saw the response in 3.10 just like in 3.9.
That makes me think that potentially urllib3
should make this change, to match the behaviour with the broken pipes.
I met the same problem as you when I trying to connect yahoo finance. When I was using old version of urllib3 it seems work fine, but now I got this error urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='finance.yahoo.com', port=443): Max retries exceeded with url: /quote/EQH (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:997)'))) hope they can look into it
I met the same problem, but after add param chunked=True
for urlopen
, it fixed. You can try this param.
Apologies if this is not the right place for this - I was torn between here and StackOverflow.
Summary: Code raises an exception on Python 3.10.6 and not Python 3.9.13. I would like to fully understand why and hopefully avoid the exception.
Simple reproducible case:
In Python 3.9, I get no exception. I see:
This is the response that I want.
In Python 3.10, I get the following traceback:
python -c "import ssl; print(ssl.OPENSSL_VERSION)"
showsOpenSSL 1.1.1q 5 Jul 2022
for both Python 3.9 and Python 3.10.requests
but I narrowed the example tourllib3
.What I have tried so far:
ssl.OP_IGNORE_UNEXPECTED_EOF
is new in Python 3.10, and that looks relevant. However, it only works with OpenSSL >= 3.0.0. I need to support Python with OpenSSL 1.1.1q.What I tried:
Likely irrelevant code
```python # I forget where I got this list from. cipher_list = [ "!MD5", "!aNULL", "!eNULL", "AES128-GCM-SHA256", "AES128-GCM-SHA256", "AES128-SHA", "AES128-SHA256", "AES256-GCM-SHA384", "AES256-SHA", "AES256-SHA256", "DES-CBC3-SHA", "DH+3DES", "DH+AES", "DH+AES256", "DH+AESGCM", "DH+HIGH", "DHE-RSA-AES128-SHA", "DHE-RSA-AES256-SHA", "ECDH+3DES", "ECDH+AES128", "ECDH+AES256", "ECDH+AESGCM", "ECDH+HIGH", "ECDHE-ECDSA-AES128-SHA", "ECDHE-ECDSA-AES256-SHA", "ECDHE-RSA-AES128-SHA", "RSA+3DES", "RSA+AES", "RSA+AESGCM", "RSA+HIGH", "TLS_AES_128_GCM_SHA256", "TLS_AES_256_GCM_SHA384", "TLS_CHACHA20_POLY1305_SHA256", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA", "TLS_DHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA", "TLS_DHE_RSA_WITH_AES_256_CBC_SHA256", "TLS_DHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_DHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_ECDHE_RSA_AES_256_CBC_SHA1", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256", "TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA", "TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384", "TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256", "TLS_EMPTY_RENEGOTIATION_INFO_SCSV", "TLS_RSA_WITH_AES_128_CBC_SHA", "TLS_RSA_WITH_AES_128_CBC_SHA256", "TLS_RSA_WITH_AES_128_GCM_SHA256", "TLS_RSA_WITH_AES_256_CBC_SHA", "TLS_RSA_WITH_AES_256_CBC_SHA256", "TLS_RSA_WITH_AES_256_GCM_SHA384", ] ciphers = ":".join(cipher_list) urllib3.util.ssl_.DEFAULT_CIPHERS = ciphers ```Context
I am building a mock for the
'https://cloudreco.vuforia.com/v1/query'
service. I want the mock to behave the same when a body is too large as the real service does, so that the users of the mock can handle errors correctly. In this case, arequests
user for example may need totry ... except SSLError: ...
with the real service, and I want them to hit this same error when using the mock. If I can fully understand what the difference is in the (handling of the) request from Python 3.9 versus Python 3.10, I hope that this will help me to make the mock more accurate, or at least document the exact scenarios in which it is not accurate.