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
uvicorn doesn't seem to pass websocket 'subprotocol' correctly back to client #1778
Comments
@villekr What happens on the We should make use of the |
I tested the example with 'wsproto' (on the asgi server side) and the result is identical. Example code is also updated to have ws="wsproto" argument by default for now. |
This seems to be an issue in the latest 0.20.0 release. In 0.19.0 (and also in 0.18.3) there are no extra 'sec-websocket-protocol: ocpp2.0.1, ocpp2.0, ocpp1.6' sent from server. logs from client with uvicorn 0.20.0:
|
It was probably introduced on #1606. |
You aren't supposed to send the The server should be in charge of doing it. It's the subprotocol the server is able to use from the list the client proposed. |
Thanks, that's correct. My mistake. |
Discussed in #1777
Originally posted by villekr November 26, 2022
Full example demonstrating the problem is here https://github.com/villekr/uvicorn-websockets-example.
python 3.10.2.
uvicorn 0.20.0
websockets 10.4
During websocket connection I'm sending "websocket.accept" with specific "subprotocol" value. Looks like that uvicorn correctly gets that value and sends it to client as 'Sec-WebSocket-Protocol' header but it also sends 'sec-websocket-protocol' header with all supported subprotocols. Websockets library requires exactly one subprotocol value and therefore errors out in this situation.
Is this a bug or should I use uvicorn differently?
Logs from server (uvicorn with debug loglevel):
logs from client:
The text was updated successfully, but these errors were encountered: