socket.io-client-swift
socket.io-client-swift copied to clipboard
Connecting to the server with nginx load balancer sends socket.io iOS client into reconnection spiral
I use socket.io version v.16.0.1, iOS 15.5.
My configuration is this:
Then I just call this method once:
manager.defaultSocket.connect()
The problem: Connecting to the server with nginx load balancer sends socket.io iOS client into reconnection spiral. According to the logs, the engine is being constantly recreated without stopping.
Calling this doesn't stop the manager from being disposed and logs show that it still tries to reconnect.
func closeConnection() {
socket.removeAllHandlers()
socket.disconnect()
manager.disconnect()
}
Essentially, you cannot stop this process, and eventually it brings the server down because of spamming an enormous number of connection requests.
Expected behavior: Socket client should respect reconnection intervals and don't fall into spiral of recreating engines and sending attempts to reconnect dozens of times in a couple of seconds.
Logs example:
These logs repeat forever, so essentially it recreates the engine and starts it again.
Hi @nuclearace For me it seems like a serious bug in connection logic
@Ariandr Thanks for reporting this. Does this reconnect spiral happen every time something happens to the client that causes it to reconnect? Or does it try to reconnect after you try and call close on the socket?
Also, does this only happen with nginx in front on the server? That might be more tricky for me to reproduce.
Hi @nuclearace It happens regardless of trying to close the connection or no.
You just execute connect()
method and it goes into the spiral. Closing just doesn't stop it.
Also, does this only happen with nginx in front on the server? That might be more tricky for me to reproduce.
Maybe it can be any load balancer that doesn't let you socket connection to remain open. But in my case it was nginx.