Hello. Thank you for library.
I socket created with .Reconnects(true) is it possible to stop reconnection when it is required?
attempt 1:
socket.on("reconnectAttempt") { [unowned self] (data, ack) -> Void in
Log.info("reconnectAttempt: \(data) | status: \(self.socket.status)")
self.socket.disconnect()
}
It crashed sometimes, in reason for
// line 202 SocketIO/SocketIOClient.swift
public func disconnect() {
assert(status != .NotConnected, "Tried closing a NotConnected client")
Sometimes it not crashed, but reconnection loop not stops too.
attempt 2: Set socket to nil and recreate it with same settings. Also fails, in reason of old client continue reconnection attempts. In logs i have two countdowns:
SocketConnector.swift:133: reconnectAttempt: [4]
SocketConnector.swift:133: reconnectAttempt: [3]
SocketConnector.swift:133: reconnectAttempt: [4]
SocketConnector.swift:133: reconnectAttempt: [2]
SocketConnector.swift:133: reconnectAttempt: [3]
SocketConnector.swift:133: reconnectAttempt: [1]
SocketConnector.swift:133; reconnectAttempt: [2]
SocketConnector.swift:133: reconnectAttempt: [1]
I can suppose i use it wrong way in reason of luck theoretical knowledge about sockets. But this lib has api which do not work as expected from it's naming.
Questions:
– What i am doing wrong?
– Is there are way to have automatic reconnection but cancel it in any time?
– According to line 202 SocketIO/SocketIOClient.swift – why is that? Why you can not just ignore disconnect request if socket was not connected? Strictly speaking task already done – no connection. or i miss something?
try setting socket.reconnects to false
Thank you
Did that solve your problem?
Yes, thank you. I am sorry do not mentions that.
Most helpful comment
try setting
socket.reconnectstofalse