Skip to content

ReadTimeout - SSL shutdown timed out #384

Description

@Kludex

Originally opened by @ScottSturdivant on 2020-05-30 08:49:00 in encode/httpx

Hi,

Just curious if someone might have some insight as to what might be happening here. I have some code that is subscribing to messages via an SSE server. The code is very similar to this:

importasyncioimporthttpxclient=httpx.AsyncClient()
asyncdefsse():
asyncwithclient:
asyncwithclient.stream('GET', 'https://server.blargh.home:5000/stream', timeout=None) asresponse:
asyncforchunkinresponse.aiter_raw():
yieldchunkasyncdefsubscribe():
asyncforeventinsse():
print(repr(event))
asyncio.run(subscribe())

On one device in particular, about 40% of the time, I'm seeing that httpcore._exceptions.ReadTimeout is raised from the aiter_raw(). Here is the traceback:

 async for chunk in response.aiter_raw():
async for chunk in self.aiterator:
async for chunk in self.stream:
async for part in self._raw_stream:
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_async/base.py", line 57, in __aiter__
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_async/connection_pool.py", line 49, in __aiter__
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpx/_models.py", line 1009, in aiter_raw
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/pygw/core/client.py", line 175, in sse
ERROR: Other SSE failure.
Traceback (most recent call last):
data = await self.socket.read(self.READ_NUM_BYTES, timeout)
event = await self._receive_event(timeout)
raise to_exc(exc) from None
self.stream_reader.read(n), timeout.get("read")
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_async/http11.py", line 128, in _receive_response_data
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_async/http11.py", line 145, in _receive_event
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_backends/asyncio.py", line 135, in read
File "/usr/local/packages/python3_7_acap/python3.7/lib/python3.7/site-packages/httpcore/_exceptions.py", line 12, in map_exceptions
File "<pyrun>/contextlib.py", line 130, in __exit__
httpcore._exceptions.ReadTimeout: SSL shutdown timed out

The stream is pretty dead. Every ~ 5 minutes a heartbeat is sent but otherwise it is generally quiet. This problem is only happening on one device and it happens to be running PyRun as its interpreter. Perhaps that's making some difference.

As it is, I have a try/except around the async with client so the stream is able to be re-established and works. Just trying to figure out what might be generating this and if there's some system configuration that needs to be done, or...

Thank you for any help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions