Ping/pong on websocket every few seconds forever #2075
-
DescriptionI'm trying to minimize unnecessary traffic to my web server and I see that the nicegui server and client are constantly sending ping/pong messages along their websocket every few seconds. To reproduce:
Is there a specific reason that the default values for these ping intervals that are this chatty? With the current defaults, a computer that someone simply stops using and walks away from with an idle page will continue to eat your server resources. I'd like to be able to tune these parameters. Is there a document that describes the tuning of these parameters? Things like:
I understand that a total disconnect would be difficult, although one could imagine pickling the specific client's server state to a database after a long-enough idle period... Any advice on these topics? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi @sklibanov312, the ping interval is basically controlled by the The ping interval is set in nicegui.py like this: Lines 90 to 91 in 59546fb For a reconnect timeout of 10 seconds the ping interval is 8 seconds, just as you measured empirically. To reduce the ping interval, the easiest thing would be to increase the reconnect timeout via from nicegui import core
core.sio.eio.ping_interval = ...But it shouldn't exceed the reconnect timeout. |
Beta Was this translation helpful? Give feedback.

Hi @sklibanov312, the ping interval is basically controlled by the
reconnect_timeoutinui.runwhich defaults to 3 seconds. On nicegui.io, however, we set it to 10 seconds. This is the time the server waits for the client to reconnect after the connection got lost, before the client is removed and resources are freed up.The ping interval is set in nicegui.py like this:
nicegui/nicegui/nicegui.py
Lines 90 to 91 in 59546fb
For a reconnect timeout of 10 seconds the ping interval is 8 seconds, just as you measured empirically.
To reduce t…