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

Handle socket errors gracefully #30

Open
Aergonus opened this issue Feb 6, 2022 · 1 comment
Open

Handle socket errors gracefully #30

Aergonus opened this issue Feb 6, 2022 · 1 comment
Labels
bug Something isn't working Stale

Comments

@Aergonus
Copy link

Aergonus commented Feb 6, 2022

For a long running realtime subscription, I find that it breaks randomly after a few hours. I would expect this to gracefully reconnect. This using simple https://github.com/supabase-community/realtime-py#sample-usage-with-supabase

2022-02-03 09:37:25,734:ERROR - Connection closed
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 750, in transfer_data
    message = await self.read_message()
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 819, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 895, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 975, in read_frame
    extensions=self.extensions,
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/framing.py", line 55, in read
    data = await reader(2)
  File "/usr/lib/python3.7/asyncio/streams.py", line 679, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/lib/python3.7/asyncio/streams.py", line 473, in _wait_for_data
    await self._waiter
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 801, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/realtime/connection.py", line 65, in _listen
    msg = await self.ws_connection.recv()
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 421, in recv
    await self.ensure_open()
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 726, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
2022-02-03 09:37:29,153:ERROR - Connection with server closed
Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 750, in transfer_data
    message = await self.read_message()
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 819, in read_message
    frame = await self.read_data_frame(max_size=self.max_size)
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 895, in read_data_frame
    frame = await self.read_frame(max_size)
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 975, in read_frame
    extensions=self.extensions,
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/framing.py", line 55, in read
    data = await reader(2)
  File "/usr/lib/python3.7/asyncio/streams.py", line 679, in readexactly
    await self._wait_for_data('readexactly')
  File "/usr/lib/python3.7/asyncio/streams.py", line 473, in _wait_for_data
    await self._waiter
  File "/usr/lib/python3.7/asyncio/selector_events.py", line 801, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/me/.local/lib/python3.7/site-packages/realtime/connection.py", line 110, in _keep_alive
    await self.ws_connection.send(json.dumps(data))
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 471, in send
    await self.ensure_open()
  File "/home/me/.local/lib/python3.7/site-packages/websockets/legacy/protocol.py", line 726, in ensure_open
    raise self.connection_closed_exc()
websockets.exceptions.ConnectionClosedError: code = 1006 (connection closed abnormally [internal]), no reason
@anand2312 anand2312 added the bug Something isn't working label May 10, 2022
@ghost ghost mentioned this issue Nov 4, 2022
Copy link
Contributor

github-actions bot commented May 2, 2024

This issue is stale because it has been open for 365 days with no activity.

@github-actions github-actions bot added the Stale label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Stale
Projects
None yet
Development

No branches or pull requests

2 participants