Socket.io触发“断开"连接时的延迟.事件? [英] Socket.io delay in firing the "disconnect" event?

查看:362
本文介绍了Socket.io触发“断开"连接时的延迟.事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个连接到node.js服务器的socket.io客户端.如果我在命令行中杀死了node.js,客户端将立即冻结(即,通信停止),但是在触发断开连接"事件之前会有大约20秒的延迟.这是设计使然吗?是否有配置选项可以减少触发断开连接事件的延迟?

I have a socket.io client connected to a node.js server. If I kill node.js at the command line, the client immediately freezes (i.e., communication stops), but there is a ~20 second delay before the "disconnect" event is fired. Is this behavior by design? Is there a configuration option to reduce the delay in firing the disconnect event?

似乎此行为在socket.io的相对较新的(最近6个月)更新中发生了变化.在将重新连接功能内置到socket.io本身之前,我使用断开连接"事件处理程序实现了自己的重新连接逻辑,当时,当服务器通信停止时,断开连接"事件几乎立即触发.

It appears that this behavior changed in a relatively recent (last 6 months) update of socket.io. Before the reconnect functionality was built in to socket.io itself, I implemented my own reconnect logic using a "disconnect" event handler and at that time the "disconnect" event fired almost instantly when server communication halted.

推荐答案

是. 关闭超时.

这篇关于Socket.io触发“断开"连接时的延迟.事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆