Closed ExoticObjects closed 9 years ago
The client is being released. Be sure the client is a member of something. Otherwise it'll be released when it goes out of scope
What do you mean by 'a member of something?' It's an application that's running - it doesn't do anything to go out of scope.
Actually, I think I know what you mean. Let me test...
Yup - for anyone who comes across this issue, it's simple, but maybe not obvious. SocketIOClient * socket
was declared inside a function. When the variable was deallocated, the socket disconnected. That's a good thing, of course! Declaring the variable as a class member fixed the problem.
Thanks!
Just curious why SocketClient
seems to always need to disconnect and reconnect several times before it successfully connects. Still getting the deinits even though the client is not being released.
Here's some log output:
SocketClient: Adding handler for event: connect
SocketClient: Adding engine
SocketEngine: Starting engine
SocketEngine: Handshaking
ERROR SocketClient: Error: The operation couldn’t be completed. Connection refused
SocketClient: Handling event: error with data: Optional([The operation couldn’t be completed. Connection refused])
SocketClient: Handling event: reconnect with data: Optional([The operation couldn’t be completed. Connection refused])
SocketClient: Starting reconnect
SocketClient: Trying to reconnect
SocketClient: Handling event: reconnectAttempt with data: Optional([-1])
SocketClient: Adding engine
SocketEngine: Starting engine
SocketEngine: Handshaking
SocketEngine: Engine is being deinit
ERROR SocketClient: Error: The operation couldn’t be completed. Connection refused
SocketClient: Handling event: error with data: Optional([The operation couldn’t be completed. Connection refused])
SocketClient: Trying to reconnect
SocketClient: Handling event: reconnectAttempt with data: Optional([-2])
SocketClient: Adding engine
SocketEngine: Engine is being deinit
SocketEngine: Starting engine
SocketEngine: Handshaking
ERROR SocketClient: Error: The operation couldn’t be completed. Connection refused
SocketClient: Handling event: error with data: Optional([The operation couldn’t be completed. Connection refused])
SocketClient: Trying to reconnect
SocketClient: Handling event: reconnectAttempt with data: Optional([-3])
SocketClient: Adding engine
SocketEngine: Engine is being deinit
SocketEngine: Starting engine
SocketEngine: Handshaking
ERROR SocketClient: Error: The operation couldn’t be completed. Connection refused
SocketClient: Handling event: error with data: Optional([The operation couldn’t be completed. Connection refused])
SocketClient: Trying to reconnect
SocketClient: Handling event: reconnectAttempt with data: Optional([-4])
SocketClient: Adding engine
SocketEngine: Engine is being deinit
SocketEngine: Starting engine
SocketEngine: Handshaking
SocketEngine: Got message: 0{"sid":"4ohNuVaX51BYz9PSAAAA","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
SocketEngine: Got message: 40
2015-05-15 22:56:05.768 SocketParser: Parsing 0
__49+[EXOServerController connectToFileWatcherSocket]_block_invoke
SocketParser: Decoded packet as: SocketPacket {type: 0; data: nil; id: nil; placeholders: nil;}
@"socket connected" = socket connected
SocketClient: Socket connected
SocketClient: Handling event: connect with data:
I'm not sure why it's saying connection refused. But it readds the engine when connecting, so that's normal.
Hi,
Upon attempting to connect, using this code:
I get these log messages:
So it appears
SocketIOClient
is trying to connect, then immediately disconnecting -socket on:@"connect"
never fires.I'm using a node server with this version of socket.io:
FWIW, I'm able to connect to the server using SIOSocket. But that's on iOS (it's not available for OSX - which is where I'm connecting now...) So I don't think anything is wrong with the server.
Any idea why this might happen?