Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do retry on urllib3.ProtocolErrors #52

Open
hampusjohansson1 opened this issue Oct 14, 2020 · 2 comments
Open

Do retry on urllib3.ProtocolErrors #52

hampusjohansson1 opened this issue Oct 14, 2020 · 2 comments

Comments

@hampusjohansson1
Copy link

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)', `

@hampusjohansson1 hampusjohansson1 changed the title Do not retry on urllib3.ProtocolError Do retry on urllib3.ProtocolErrors Oct 14, 2020
@FlavorFx
Copy link

FlavorFx commented Apr 5, 2021

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?

@troy8
Copy link

troy8 commented Jul 5, 2021

Any update on this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants