I use Socket IO v13.1.1 on iOS app with server (apache nginx, Socket IO v2.0.4). We test what will happen if server reboots.
iOS library constantly emits reconnectAttempt event (default config). Why it doesn't reconnects?
Is iOS app supposed to perform some custom actions?
I was able to fix my problem by disabling built-in reconnection:
manager = SocketManager(socketURL: serverURL, config: [.reconnects(false)])
And then I created a Timer that will periodically check if the socket is connected and reconnects if necessary.
I have the same problem
Sorry for missing this. Does the logs spit out something about an unknown session id?
I have the same issue.
If I listen to the 'reconnectAttempt' event, which is still fired as expected, and in that I call disconnect on the SocketManager, the reconnect attempt will work. This doesn't seem to fire the 'disconnect' event.
It may be worth noting that the socket in question is on a non-root namespace
```
2018-06-18 18:29:05.424781+0100 four[2661:2628085] LOG SocketManager: Starting reconnect
2018-06-18 18:29:05.425002+0100 four[2661:2628085] LOG SocketIOClient{/ipad}: Handling event: statusChange with data: [connecting]
2018-06-18 18:29:05.425093+0100 four[2661:2628085] LOG SocketIOClient{/ipad}: Handling event: reconnect with data: ["Socket Disconnected"]
Reconnect
2018-06-18 18:29:05.425401+0100 four[2661:2628085] LOG SocketManager: Trying to reconnect
2018-06-18 18:29:05.425491+0100 four[2661:2628085] LOG SocketIOClient{/ipad}: Handling event: reconnectAttempt with data: [-1]
Reconnect Attempt
2018-06-18 18:29:05.437001+0100 four[2661:2628085] LOG SocketManager: Adding engine
2018-06-18 18:29:05.437254+0100 four[2661:2628112] LOG SocketEngine: Engine is being released
2018-06-18 18:29:05.437425+0100 four[2661:2628251] LOG SocketEngine: Starting engine. Server: https://xxxx
2018-06-18 18:29:05.437449+0100 four[2661:2628251] LOG SocketEngine: Handshaking
2018-06-18 18:29:05.437613+0100 four[2661:2628251] LOG SocketEnginePolling: Doing polling GET https://xxxx/socket.io/?transport=polling&b64=1
2018-06-18 18:29:05.438333+0100 four[2661:2628123] TIC Read Status [1:0x0]: 1:57
2018-06-18 18:29:05.438352+0100 four[2661:2628123] TIC Read Status [1:0x0]: 1:57
2018-06-18 18:29:05.561286+0100 four[2661:2628112] LOG SocketEnginePolling: Got polling response
2018-06-18 18:29:05.561445+0100 four[2661:2628112] LOG SocketEnginePolling: Got poll message:
2018-06-18 18:29:05.561648+0100 four[2661:2628112] LOG SocketEngine: Got message:
2018-06-18 18:29:05.562229+0100 four[2661:2628085] ERROR SocketManager: Got unknown error from server
2018-06-18 18:29:05.562381+0100 four[2661:2628085] LOG SocketIOClient{/ipad}: Handling event: error with data: ["Got unknown error from server rn
The socket manager is a property of a singleton class that is never disposed of
Disconnecting manager first works for me.
My code is as follow
socket?.onAny { (data) in
if data.event == "reconnectAttempt" {
self.socketManager?.disconnect()
self.connectSocket()
}
}
Yeah I got it to work doing the same thing, #909 has a proposed fix that seems to make sense
I can confirm the same thing. After adding [self.manager disconnect]; before every [self.socket disconnect]; in my code, things are working as expected again.
Most helpful comment
Disconnecting manager first works for me.
My code is as follow