sseclient
sseclient copied to clipboard
Do retry on urllib3.ProtocolErrors
When reading responses at self.resp.raw.read, a protocol error might occur, for example, when the connection is somehow disturbed. On such an error, we want to retry and connect to the server again, as with the other errors. Presently this is not the case, since the protocol error isn't caught.
Stacktrace
` File "/usr/local/lib/python2.7/dist-packages/sseclient.py", line 92, in next next_chunk = next(self.resp_iterator)
File "/usr/local/lib/python2.7/dist-packages/sseclient.py", line 76, in generate chunk = self.resp.raw.read(self.chunk_size)
File "/usr/lib/python2.7/dist-packages/urllib3/response.py", line 459, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib/python2.7/contextlib.py", line 35, in exit self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/dist-packages/urllib3/response.py", line 378, in _error_catcher raise ProtocolError('Connection broken: %r' % e, e)
ProtocolError: ('Connection broken: IncompleteRead(831 bytes read)', `
I think I'm facing the same issue. When I lost the connection (no connection to the router nor to the router) a time out occurred. The SSE server connection failed and there is no way to reconnect. Unfortunately this happens quite often due to my worse internet connection.
Traceback (most recent call last): File "/workspaces/core.homeconnect/config/custom_components/home_connect_neo/sseclient.py", line 87, in __next__ next_chunk = next(self.resp_iterator) File "/workspaces/core.homeconnect/config/custom_components/home_connect_neo/sseclient.py", line 68, in generate chunk = self.resp.raw._fp.fp.read1(self.chunk_size) File "/usr/local/lib/python3.8/socket.py", line 669, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.8/ssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.8/ssl.py", line 1099, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out
Is there a way to reestablish the connection?
Any update on this issue?