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

python: Fix Litestar WebSockets compatibility #1549

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ac000
Copy link
Member

@ac000 ac000 commented Jan 27, 2025

    python: Fix Litestar WebSockets compatibility
    
    It was reported on GitHub that Unit was unable to work with WebSockets
    under Litestar Python applications.
    
    This was due to Unit sending a 'method' variable in the WebSocket's
    connection scope, which Litestar was interpreting as being a normal HTTP
    connection.
    
    The ASGI WebSocket specification makes no mention about setting a
    'method', so let's not send it on WebSockets.
    
    Also tested this change with basic ASGI WebSockets and FastAPI
    WebSockets and obviously pytests still pass.

    Closes: https://github.com/nginx/unit/issues/1507
    Link: <https://asgi.readthedocs.io/en/latest/specs/www.html#websocket-connection-scope>
    Signed-off-by: Andrew Clayton <[email protected]>

It was reported on GitHub that Unit was unable to work with WebSockets
under Litestar Python applications.

This was due to Unit sending a 'method' variable in the WebSocket's
connection scope, which Litestar was interpreting as being a normal HTTP
connection.

The ASGI WebSocket specification makes no mention about setting a
'method', so let's not send it on WebSockets.

Also tested this change with basic ASGI WebSockets and FastAPI
WebSockets and obviously pytests still pass.

Closes: nginx#1507
Link: <https://asgi.readthedocs.io/en/latest/specs/www.html#websocket-connection-scope>
Signed-off-by: Andrew Clayton <[email protected]>
@ac000 ac000 marked this pull request as ready for review January 27, 2025 17:58
@ac000 ac000 requested review from hongzhidao and avahahn January 27, 2025 17:58
@ac000 ac000 linked an issue Jan 27, 2025 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

Nginx Unit not conforming to ASGI spec on websocket connections
2 participants