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_ping_event() occasionally sends to closed socket #184

Open
brandyn opened this issue Nov 14, 2023 · 0 comments
Open

_handle_ping_event() occasionally sends to closed socket #184

brandyn opened this issue Nov 14, 2023 · 0 comments

Comments

@brandyn
Copy link

brandyn commented Nov 14, 2023

The short of it is that _handle_ping_event() sometimes tries to send a reply to a closing socket, which raises an (avoidable) exception from within the websocket thread.

This can lead to unexpected MultiErrors crashing the app. That should be improved with python 3.11's ExceptionGroups, but still there's no reason for websockets to be throwing this particular exception while closing down a pipe.

Here is the exception:

  Traceback (most recent call last):
    File ".../python3.10/site-packages/trio_websocket/_impl.py", line 1205, in _reader_task
      await handler(event)
    File ".../python3.10/site-packages/trio_websocket/_impl.py", line 1145, in _handle_ping_event
      await self._send(event.response())
    File ".../python3.10/site-packages/trio_websocket/_impl.py", line 1249, in _send
      data = self._wsproto.send(event)
    File ".../python3.10/site-packages/wsproto/__init__.py", line 64, in send
      data += self.connection.send(event)
    File ".../python3.10/site-packages/wsproto/connection.py", line 107, in send
      raise LocalProtocolError(
  wsproto.utilities.LocalProtocolError: Event Pong(payload=bytearray(b'')) cannot be sent in state ConnectionState.LOCAL_CLOSING.
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

1 participant