Closing websocket when connecting #2867
Unanswered
ivanthewebber
asked this question in
Potential Issue
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I want to confirm my understanding of a bug in my code and to learn the best practice.
Browser websockets tend to display only 1006 if the connection handshake fails (e.g. due to auth HTTP 403 or rate limiting 429), so I wanted to try closing before raising HTTPException, but this resulted in the error:
RuntimeError: Expected ASGI message 'websocket.http.response.body' but got 'websocket.http.response.start'.. I take it to mean that I can't both fail before accept with HTTPException and close the websocket.Is the best practice to raise WebSocketException? Most of our middleware and dependencies were originally implemented for our HTTP routes so they raise HTTPException which should be fine before the handshake is complete right?
Beta Was this translation helpful? Give feedback.
All reactions