Socket.io client fails to reconnect to server after an abrupt disconnection

时间:2017-06-04 23:47:48

标签: ios node.js swift socket.io

I am using the socket.io NodeJs server library and the Swift client library. Majority of the time the client successfully reconnects to the server after a disconnection, however intermittently we are seeing abrupt disconnections and then the client is never able to reconnect.

In the server logs, I see the client sending a connection attempt at the defined re-try interval, however it just never successfully establishes the connection and then we get a ping timeout.

There is surprisingly very little support for Socket.io which makes this extremely difficult to solve.

1 个答案:

答案 0 :(得分:1)

通过在重新连接时强制在客户端中创建新引擎,我找到了解决问题的方法。创建SocketIOClient对象时,将forceNew变量设置为true,允许客户端创建新引擎,从而始终成功建立连接。

return SocketIOClient(socketURL: socketURL, config: [.forceNew(true)])