Skip to content

TCPServer crash #329

@apawlucz-cisco

Description

@apawlucz-cisco

When not using the websocket.close() as part of the endpoint definition - it causes the TCPServer to crash, which causes drop of all the connection establish with this TCSPServer instance. E.g. multiple onging websocket connections.

This issue is very similar to: #327

The very same app can be used for repro as mentioned here: #327 (comment)

Before running the app - make sure the close line in the main_hypercorn.py is COMMENTED:

await websocket.send_bytes(data)
# Commented on purpose - no explicit close
# await websocket.close()

The issue only happens if:

  1. There is a permanent Websocket connection created (app button "Connect to /permanent").
  2. The 1. connection is created using HTTP2 (sometimes it's neccessary to use hard reload on the app and try several times so the connection is established using HTTP2).
  3. While the permanent connection is established - then try to create another websocket connection (button "Connect to /ws").

If this happens this traceback can be seen:

    |   File "[...]/venvs/3.11/core/lib/python3.11/site-packages/hypercorn/protocol/h2.py", line 189, in handle
    |     await self._handle_events(events)
    |   File "[...]/venvs/3.11/core/lib/python3.11/site-packages/hypercorn/protocol/h2.py", line 252, in _handle_events
    |     await self.streams[event.stream_id].handle(
    |           ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
    | KeyError: 61
    +------------------------------------

This causes the TCPServer to crash and closes both websocket connections.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions