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.
答案 0 :(得分:1)
通过在重新连接时强制在客户端中创建新引擎,我找到了解决问题的方法。创建SocketIOClient
对象时,将forceNew
变量设置为true
,允许客户端创建新引擎,从而始终成功建立连接。
return SocketIOClient(socketURL: socketURL, config: [.forceNew(true)])