Skip to content

Inconsistent WebSocket subprotocol parsing compared to other ASGI servers #815

@david-sh-csiro

Description

@david-sh-csiro

I have observed an inconsistency in how WebSocket subprotocols are handled compared to other ASGI server implementations.
Specifically, Granian does not split the Sec-WebSocket-Protocol header into separate subprotocol strings. Instead, it returns a single combined string.

Client Websocket Opening Handshake
Sec-WebSocket-Protocol: bokeh, Token

Observed Behavior (Granian)

scope["subprotocols"] == ['bokeh, Token']

Expected / Common Behavior (Other ASGI servers)
Other ASGI servers such as Uvicorn, Hypercorn, and Daphne split the subprotocol header into a list of individual protocol strings:

scope["subprotocols"] == ['bokeh', 'Token']

This behavior was observed when using Django together with bokeh_django under Granian.

Other ASGI servers split the header value. Returning a single combined string may cause compatibility issues with frameworks or libraries that expect a list of individual subprotocols.

Is this behaviour intentional? If not, would it be possible to align Granian’s handling of WebSocket subprotocols with other ASGI server implementations?

Metadata

Metadata

Assignees

No one assigned

    Labels

    asgiIssue related to ASGI protocolbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions