Is there a way to change the timeout Meteor handles for dropped connections?
Use case: We have a server, connected to several clients. Once the connection drops on a client, for example by pulling out the ethernet cable, we want to reflect that the client has gone offline. However, since the connection timeout seems to be about 30 seconds, it takes about this long for the server to notice the disconnection and put the client as offline.
Things we have tried: - Changing the heartbeat rate on the clients, which works for the clients, as they drop the connection sooner. This does not affect behaviour on the server though, as the server still waits about 30 seconds to call the connection drop.
I've been unable to find anything in the documentation in regards to decreasing the timeout for connections.
Meteor uses SockJS as its websocket server.
The disconnect delay was set to 60 seconds in the early days of Meteor due to performance issues (users were getting disconnected if the cpu was busy for too long), and cannot be configured.
// The default disconnect_delay is 5 seconds, but if the server ends up CPU
// bound for that much time, SockJS might not notice that the user has
// reconnected because the timer (of disconnect_delay ms) can fire before
// SockJS processes the new connection. Eventually we'll fix this by not
// combining CPU-heavy processing with SockJS termination (eg a proxy which
// converts to Unix sockets) but for now, raise the delay.
disconnect_delay: 60 * 1000,
source: Meteor ddp-server package
You will most likely need to fork the ddp-server
package and override it if you want this changed quickly.