Closed tomchristie closed 2 years ago
Right, I've tracked this one down.
See also https://github.com/encode/httpcore/issues/396 which is the same thing again.
I'l open an issue against anyio
to deal with this case.
Updating to the latest version of anyio should now resolve this. 👍
Thanks for the report. 😊
I can reproduce discussion #1842, in a very simple example:
Which raises an
httpx.ReadError()
full traceback
```python Traceback (most recent call last): File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/anyio/streams/tls.py", line 102, in _call_sslobject_method result = func(*args) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ssl.py", line 718, in read v = self._sslobj.read(len) ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:2555) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_backends/anyio.py", line 60, in read return await self.stream.receive(n) File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/anyio/streams/tls.py", line 152, in receive data = await self._call_sslobject_method(self._ssl_object.read, max_bytes) File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/anyio/streams/tls.py", line 121, in _call_sslobject_method raise BrokenResourceError from exc anyio.BrokenResourceError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Users/tomchristie/GitHub/encode/httpx/httpx/_transports/default.py", line 62, in map_httpcore_exceptions yield File "/Users/tomchristie/GitHub/encode/httpx/httpx/_transports/default.py", line 201, in __aiter__ async for part in self._httpcore_stream: File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_async/connection_pool.py", line 57, in __aiter__ async for chunk in self.stream: File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_bytestreams.py", line 91, in __aiter__ async for chunk in self._aiterator: File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_async/http11.py", line 208, in _receive_response_data event = await self._receive_event(timeout) File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_async/http11.py", line 225, in _receive_event data = await self.socket.read(self.READ_NUM_BYTES, timeout) File "/Users/tomchristie/GitHub/encode/httpx/venv/lib/python3.7/site-packages/httpcore/_backends/anyio.py", line 65, in read raise ReadError from exc httpcore.ReadError The above exception was the direct cause of the following exception: Traceback (most recent call last): File "./example.py", line 46, inAnd which is different behaviour from the sync equivalent.
I haven't managed to dig into why the SSL behaviour is different in the two cases here, but it's clearly something worth looking at in more detail.
httpx
this fails on bothasyncio
and, and fails both withtrio
verify=False
and without it. Edit: I don't think this does fail on the latest versions of trio.aiohttp
this raises a certificate error, unlessssl=False
is passed, in which case everything runs okay.httpx
. (Haven't checkedrequests
)