Meteor连接超时调整

Meteor connection timeout adjustment

有没有办法更改 Meteor 处理断开连接的超时时间?

用例: 我们有一个服务器,连接到多个客户端。一旦客户端连接断开,例如通过拔出以太网电缆,我们想要反映客户端已离线。但是,由于连接超时似乎是 30 秒左右,因此服务器需要大约这么长时间才能注意到断开连接并将客户端置于离线状态。

我们尝试过的事情: - 更改客户端的心跳率,这对客户端有效,因为它们会更快地断开连接。不过,这不会影响服务器上的行为,因为服务器仍会等待大约 30 秒来调用连接断开。

我在文档中找不到任何关于减少连接超时的内容。

Meteor 使用 SockJS 作为其 websocket 服务器。

Meteor 早期由于性能问题设置为 60 秒断开连接延迟(如果 cpu 忙太久,用户会断开连接),无法配置。

// 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,

来源:Meteor ddp-server package

如果您希望快速更改,您很可能需要分叉 ddp-server 包并覆盖它。