disconnect callback not instant
Disconnect callback is not called instantly on client (browser) close. Rather it takes few seconds. What can be best way, if possible to know instantly when client disconnects?
Set a lower connection timeout in your server.
https://github.com/abourget/gevent-socketio/blob/668d11edbd62052cde1583be1e1d0512c930f16d/socketio/server.py#L37-L49
:param heartbeat_interval: int The timeout for the server, we
should receive a heartbeat from the client within this
interval. This should be less than the
``heartbeat_timeout``.
:param heartbeat_timeout: int The timeout for the client when
it should send a new heartbeat to the server. This value
is sent to the client after a successful handshake.
:param close_timeout: int The timeout for the client, when it
closes the connection it still X amounts of seconds to do
re open of the connection. This value is sent to the
client after a successful handshake.
Yes it works with that option lowered. Thanks @gordol
No problem, just keep in mind, as you scale and have more users, the increased frequency of those heartbeats will lead to more traffic, and also on some mobile networks, there may be quite a bit of latency that will cause users to become disconnected by mistake if you set the interval too low.
Computationally, and in terms of bandwidth, re-negotiation of a connection is heavier and more resource intensive than waiting a few extra seconds for a client time-out. But, it's really a micro-optimization, at this point. Just things to consider later if/when you're scaling... Best of luck!
@gordol how to set that value?