Meteor connection timeout adjustment

Is there a way to change the Meteor handles timeout for dropped connections?

Use case: We have a server connected to multiple clients. When the connection drops to the client, for example pulling out the Ethernet cable, we want to reflect that the client is disconnected. However, since the connection timeout is about 30 seconds, the server requires a disconnect notification and puts the client offline.

What we tried: - Changing heart rate on clients that works for clients as they give up early. This does not affect the behavior on the server as the server still waits for about 30 seconds to cause the connection to drop.

  • Implementation of our own heart rate method, which has an interval of 3 seconds, to detect connection drops. This, however, results in a lot of extra code for something I plan to customize.

I was unable to find anything in the documentation regarding reducing the timeout for connections.

+3


source to share


1 answer


Meteor uses SockJS as its websocket server.

The shutdown delay was set to 60 seconds in the early days of Meteor due to performance issues (users disconnected if the processor 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 package ddp-server

and override it if you want this to change quickly.

+4


source







All Articles