禁用 Socket.io 心跳 (Node.js)
socket.io 文档提到可以像这样禁用心跳:
io.disable('heartbeats');
不幸的是,虽然这似乎阻止了心跳的发送,但客户端在不发送心跳时仍然会断开连接。
以下内容也不起作用:
io.set('heartbeats', false);
我尝试将某些间隔设置为 0,但没有成功:
io.set('heartbeat timeout', 0);
io.set('heartbeat interval', 0);
关于如何正确禁用心跳的任何建议?
The socket.io documentation mentions that heartbeats can be disabled like so:
io.disable('heartbeats');
Unfortunately, while this seems to stop the hearbeats from being sent, the clients still disconnect when they are not sending hearbeats.
The following does not function either:
io.set('heartbeats', false);
I have tried setting some intervals to 0, without success:
io.set('heartbeat timeout', 0);
io.set('heartbeat interval', 0);
Any suggestions on what might properly disable heartbeats?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
该代码已
在 socket.io v0.8.7 上成功测试,
无需禁用 禁用
调试
- 客户端授权
The code is
Tested successfully on socket.io v0.8.7
Without disabling
With disabling
debug - client authorized
心跳有问题。我有最新的 socket.io 和节点 0.6.X
客户端在连接后立即断开连接。
There is something wrong with heartbeats. I have latest socket.io and node 0.6.X
Client is disconnected right after connection.
设置socket.io的日志级别,日志级别为2时,我们看不到每个套接字的所有心跳,只能看到握手和断开连接
Set the log level of socket.io, with log level 2 we wont see all the heartbeats of each socket but only the handshakes and disconnections