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

Merged
merged 1 commit into from
Feb 4, 2025
Merged

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]>

@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
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
Copy link
Member Author

ac000 commented Feb 3, 2025

Rebased with master

$ git range-diff 25dae040...c2279c0d
-:  -------- > 1:  7b7b29fc ruby: Fix build failures with Ruby 3.4
-:  -------- > 2:  15037822 Fix build with GCC 15
1:  25dae040 = 3:  c2279c0d python: Fix Litestar WebSockets compatibility

@ac000 ac000 merged commit c2279c0 into nginx:master Feb 4, 2025
23 of 24 checks passed
@ac000 ac000 deleted the asgi-ws-fix branch February 4, 2025 02:39
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