Skip to content

I have a problem about livestreaming connection starlette.websockets.WebSocketDisconnect: 1006 #2383

Answered by coolbeevip
diddmstjr07 asked this question in Q&A
Discussion options

You must be logged in to vote

This issue is very similar to mine.

I am starting a FastAPI web socket service on the server using uvicorn, and the client uses websocket-client (note that this is a synchronous client).

By default, uvicorn's ping/pong interval is 20 seconds. When the websocket-client blocks for more than 20 seconds during sending, it triggers a failure in uvicorn's ping check and actively disconnects with error code 1006.

The simple solution is to set the ws_ping_interval interval.

uvicorn.run(app, ws_ping_interval=600, ws_ping_timeout=60)

Replies: 1 comment 6 replies

Comment options

You must be logged in to vote
6 replies
@coolbeevip
Comment options

Answer selected by diddmstjr07
@ugyballoons
Comment options

@coolbeevip
Comment options

@ugyballoons
Comment options

@diddmstjr07
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #2382 on December 21, 2023 08:00.