【发布时间】:2014-06-19 22:29:17
【问题描述】:
似乎 reconnect_failed 事件在 socket.io-client 中被触发了两次。我尝试为 reconnectionAttempts 设置不同的值,但即使它是 1、2 或 3,它总是会触发事件两次。
要重现场景,请在客户端运行
var opts = { reconnection: true, reconnectionAttempts: 3, reconnectionDelay: 500}
var socket = io.connect(opts)
socket.on('reconnect_failed', function() {
console.log("Reconnect failed")
})
在运行 kill node server (CTRL+C) 时,您将在开发者工具控制台中获得以下输出:
Reconnect failed
Reconnect failed
我使用的是 socket.io 1.0.5
【问题讨论】:
标签: javascript sockets socket.io socket.io-1.0