|
Users are being disconnected by ES |
|
The ES Admin's General Settings screen allows you to configure the ClientIdleTimeout, in seconds. The default is 600, which is ten minutes. About every minute, the ES5 checks all connected users to see the last time that they sent a message to the server, and if exceeds the ClientIdleTimeout period, logs the user off. This is needed because when a client crashes, the ES5 does not notice the disconnect.
ES5.3.2 and Earlier
The best solution is to implement an anti-idle heartbeat message. The easiest heartbeat implementation uses the GetUserCountRequest message type. This is typically used to query ElectroServer for the number of users currently connected. However, we can also harness this to keep our connection active. The reason for using this message is due to its simplicity as it requires no extra parameters or even an event handler for the returning GetUserCountResponse message.
To implement, set up a timer on your client to automatically send a GetUserCountResponse message every minute. It has no parameters, and you don't even need to listen for the response unless you want to display the total number of users currently online. This message needs to be sent using your primary connection (TCP or HTTP); that is, sending it UDP will not work as a heartbeat.
See also Detecting Disconnection.
ES5.3.3 and Later
The best solution is to listen for an IdleTimeoutWarningEvent. As soon as the client hears this event, have it send a message to the server. Any message will do, but a GetUserCountRequest is easiest. This event should arrive before the user is kicked due to idleness. You can have a plugin increase the warning time if you like. For example, if the time is increased to 120001 then the client will get two events before the kick. Since the IdleMonitor on the server only checks for idleness once a minute (approximately), it is best to specify a time that is a multiple of 60000, then add 1.
This message needs to be sent using your primary connection (TCP or HTTP); that is, sending it UDP will not work to prevent the client being kicked.