-
First Check
Commit to Help
Example Code@router.websocket("/websocket")
async def websocket(websocket: WebSocket):
await websocket.accept()
try:
while websocket.client_state == WebSocketState.CONNECTED:
raw_message = await websocket.receive_bytes()
except WebSocketDisconnect:
pass
finally:
passDescriptionConnect to the endpoint using any client and make the client die abruptly. The server will fail the closing handshake, as the client is totally gone. It is usually(!) not enough to just close the browser, as it will still have the connection when the server tries to close the websocket. You might have to hit the power switch, or use some client that allows you to instantly kill the connection. I have found a connection made with Godot game engine makes it easy to reproduce, as the engine can be paused for debug and then stopped instantly. As you can imagine, it's not very good, that a client losing power will kill the server. The error is described in further detail here: Which make me think that Fastapi is using an old version of websockets? Operating SystemLinux Operating System DetailsNo response FastAPI Version0.75.0 Python Version3,9 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Downgrading to websockets==10.1 resolved the issue for me. |
Beta Was this translation helpful? Give feedback.
Downgrading to websockets==10.1 resolved the issue for me.