timeout-keep-alive applied to websockets #2124
Replies: 3 comments
-
Doing my own digging through Uvicorn, it appears that Uvicorn does nothing special here and is just leveraging the existing functionality of the python websockets library. It seems a number of people have run into similar issues and implemented their own application layer logic whereby custom ping logic in the form of text frames are handled. Whilst this kind of solves the issue, it seems like just exposing the protocol level ping frames to the application layer would be an easier fix and give better functionality and flexibility to users. |
Beta Was this translation helpful? Give feedback.
-
I have asked whether redundancy in the heartbeat can be exposed as a feature of the websockets library: python-websockets/websockets#1414 |
Beta Was this translation helpful? Give feedback.
-
Forgive me if this is due to my own misunderstanding of the http/wss protocol level. I am trying to set a keepalive timeout for a websocket connection however I have found that the
--timeout-keep-alive
variable doesnt impact the lifetime of the websocket connection. The only way I have found to manage this is to build my own keepalive timeouts on the application layer (which doesnt have access to the ping/pong logic).Ideally, I would be able to set a keepalive timeout that works for websockets on the server level to account for pings to the client. The existing ping interval and timeouts work in websockets however there is no redundancy such as a backoff feature. This means that if my websocket connection were to drop a ping frame due to packet loss, the connection would be broken once the timeout is reached despite other messages passing freely between client and server.
What is the best way of approaching this using Uvicorn? Am I using existing features incorrectly or does some work need to be undertaken on Uvicorn to surface this functionality?
Beta Was this translation helpful? Give feedback.
All reactions