Server disconnected while attempting read with async client #1689
Answered
by
tomchristie
dev-zero
asked this question in
Potential Issue
-
This initially started as an issue report here: ol-iver/denonavr#215 Some digging led me to the following minimal reproducers: import httpx
r = httpx.get('http://192.168.179.35:8080/goform/Deviceinfo.xml')
print(r) import httpx
import asyncio
async def main():
async with httpx.AsyncClient() as client:
r = await client.get('http://192.168.179.35:8080/goform/Deviceinfo.xml')
print(r)
asyncio.run(main()) Running them gives me: $ python httpx_sync_get.py
<Response [200 OK]>
$ $ python httpx_async_get.py
Traceback (most recent call last):
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 61, in map_httpcore_exceptions
yield
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 201, in __aiter__
async for part in self._httpcore_stream:
File "/home/tiziano/.local/lib/python3.9/site-packages/httpcore/_async/connection_pool.py", line 57, in __aiter__
async for chunk in self.stream:
File "/home/tiziano/.local/lib/python3.9/site-packages/httpcore/_bytestreams.py", line 91, in __aiter__
async for chunk in self._aiterator:
File "/home/tiziano/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 208, in _receive_response_data
event = await self._receive_event(timeout)
File "/home/tiziano/.local/lib/python3.9/site-packages/httpcore/_async/http11.py", line 225, in _receive_event
data = await self.socket.read(self.READ_NUM_BYTES, timeout)
File "/home/tiziano/.local/lib/python3.9/site-packages/httpcore/_backends/anyio.py", line 65, in read
raise ReadError("Server disconnected while attempting read") from None
httpcore.ReadError: Server disconnected while attempting read
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/tiziano/work/tests/python/denon/httpx_get.py", line 11, in <module>
asyncio.run(main())
File "/usr/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
return future.result()
File "/home/tiziano/work/tests/python/denon/httpx_get.py", line 7, in main
r = await client.get('http://192.168.179.35:8080/goform/Deviceinfo.xml')
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_client.py", line 1661, in get
return await self.request(
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_client.py", line 1425, in request
response = await self.send(
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_client.py", line 1528, in send
raise exc
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_client.py", line 1519, in send
await response.aread()
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_models.py", line 1561, in aread
self._content = b"".join([part async for part in self.aiter_bytes()])
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_models.py", line 1561, in <listcomp>
self._content = b"".join([part async for part in self.aiter_bytes()])
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_models.py", line 1577, in aiter_bytes
async for raw_bytes in self.aiter_raw():
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_models.py", line 1631, in aiter_raw
async for raw_stream_bytes in self.stream:
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_client.py", line 127, in __aiter__
async for chunk in self._stream:
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 202, in __aiter__
yield part
File "/usr/lib/python3.9/contextlib.py", line 135, in __exit__
self.gen.throw(type, value, traceback)
File "/home/tiziano/.local/lib/python3.9/site-packages/httpx/_transports/default.py", line 78, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ReadError: Server disconnected while attempting read
$ curl -sv http://192.168.179.35:8080/goform/Deviceinfo.xml
* Trying 192.168.179.35:8080...
* Connected to 192.168.179.35 (192.168.179.35) port 8080 (#0)
> GET /goform/Deviceinfo.xml HTTP/1.1
> Host: 192.168.179.35:8080
> User-Agent: curl/7.77.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Server: mongoose2.5
< Pragma: no-cache
< Cache-control: no-cache
< Content-Type: text/xml; charset=utf-8
<
{ [2791 bytes data]
<?xml version="1.0" encoding="utf-8" ?>
<Device_Info>
... Any ideas? |
Beta Was this translation helpful? Give feedback.
Answered by
tomchristie
Jun 16, 2021
Replies: 1 comment 4 replies
-
I'm just getting a EDIT: Resolved by |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
tomchristie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm just getting a
ConnectTimeout
when trying to replicate this?EDIT: Resolved by
httpcore 0.13.6
.