How to handle websocket disconnect from client #2543
Unanswered
MichalPham
asked this question in
Q&A
Replies: 3 comments 1 reply
-
Hi, |
Beta Was this translation helpful? Give feedback.
0 replies
-
We seem to be affected by the same issue. There seems to be a little of a disconnect between message types used for connection termination, or am I confused? |
Beta Was this translation helpful? Give feedback.
0 replies
-
I'm also receiving: RuntimeError: Expected ASGI message "websocket.receive" or "websocket.disconnect", but got 'websocket.close' Is there a version we can rollback to? |
Beta Was this translation helpful? Give feedback.
1 reply
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.
Uh oh!
There was an error while loading. Please reload this page.
-
When disconectiong from client side (httpx-ws, js) using their respective
close
methods, thestartlette.websocket.receive_(text|bytes)
fails withRuntimeError
and not withWebSocketDisconnect
. Its caused by this line because the message type iswebsocket.close
and notwebsocket.disconnect
. I have not found a way how to sendwebsocket.disconnect
looking at the implementation of starlette close method it also sendswebsocket.close
.So the question really is how do i correctly disconect from client side.
Beta Was this translation helpful? Give feedback.
All reactions