Open kinza88 opened 7 years ago
@nuclearace
Are you using your api correctly? Have you checked the server logs to see why it's disconnecting?
Hey I am sorry I got late to respond to your email. I have tried that code again. At this very point, the there is no disconnection error. But the handler is not listening the response. Request is sent, response comes back but it doesn't get listened. It gets printed in the logs only. However i could see this error:
2017-11-28 17:24:50.448986+0500 TestApiProject[8166:383893] LOG SocketEngine: Got message: {"code":1,"message":"Session ID unknown"} 2017-11-28 17:24:50.449257+0500 TestApiProject[8166:383893] ERROR SocketEngine: Session ID unknown
Can you help me regarding this? I have gone through other related issues but didn't find any appropriate help.
@kinza88 @nuclearace
Hi, I'm facing a very similar issue.
In my case this happens on macOS (didn't see similar behavior on iOS).
Although reconnection works for me, the connection with the server keeps being closed because the server didn't get the PING in time. Logging produces this output :
2017-12-01 10:16:35.897967+0100 Application[19936:973300] LOG SocketEngine: Got message: 3 2017-12-01 10:16:37.882025+0100 Application[19936:973300] LOG SocketEngine: Writing ws: has data: false 2017-12-01 10:16:37.882136+0100 Application[19936:973300] LOG SocketEngineWebSocket: Sending ws: as type: 2 2017-12-01 10:16:37.897835+0100 Application[19936:973300] LOG SocketEngine: Got message: 3 2017-12-01 10:16:39.882151+0100 Application[19936:965577] LOG SocketEngine: Writing ws: has data: false 2017-12-01 10:16:39.882520+0100 Application[19936:965577] LOG SocketEngineWebSocket: Sending ws: as type: 2 2017-12-01 10:16:39.898686+0100 Application[19936:965577] LOG SocketEngine: Got message: 3 2017-12-01 10:16:41.882477+0100 Application[19936:965577] LOG SocketEngine: Writing ws: has data: false 2017-12-01 10:16:41.883000+0100 Application[19936:965577] LOG SocketEngineWebSocket: Sending ws: as type: 2 2017-12-01 10:16:41.907961+0100 Application[19936:973300] LOG SocketEngine: Got message: 3 2017-12-01 10:16:48.909072+0100 Application[19936:965578] ERROR SocketEngine: 2017-12-01 10:16:48.909941+0100 Application[19936:959424] ERROR SocketIOClient: 2017-12-01 10:16:48.910204+0100 Application[19936:959424] LOG SocketIOClient: Handling event: error with data: [""] 2017-12-01 10:16:48.911094+0100 Application[19936:959424] LOG SocketIOClient: Handling event: statusChange with data: [SocketIO.SocketIOClientStatus] 2017-12-01 10:16:48.911310+0100 Application[19936:959424] LOG SocketIOClient: Starting reconnect 2017-12-01 10:16:48.911715+0100 Application[19936:959424] LOG SocketIOClient: Handling event: reconnect with data: [""] 2017-12-01 10:16:48.912023+0100 Application[19936:959424] LOG SocketIOClient: Trying to reconnect 2017-12-01 10:16:48.912507+0100 Application[19936:959424] LOG SocketIOClient: Handling event: reconnectAttempt with data: [-1] 2017-12-01 10:16:48.915810+0100 Application[19936:959424] LOG SocketIOClient: Handling event: statusChange with data: [SocketIO.SocketIOClientStatus] 2017-12-01 10:16:48.920342+0100 Application[19936:974381] LOG SocketEngine: Starting engine. Server: http://host.fr.office:57570 2017-12-01 10:16:48.920816+0100 Application[19936:974381] LOG SocketEngine: Handshaking // etc
The log says at some point an error is being triggered, but associated data contains an empty string, so I can't understand what's happening :
Handling event: error with data: [""]
I'm using version 12.1.3 of socket.io-client-swift, originally upgraded from 12.1.2 (same issue). I'm using default ping timeout options, ping every 2 seconds, timeout after 5 seconds, and the server promptly closes the connection. This is highly reproducible, in experiments, within 1-2 minutes the error happens.
Any clue on this ? Can it be a timer somewhere that doesn't fire or something ?
Further experiment shows the issue doesn't raise on OSX 10.10. Didn't tried on OSX 10.11, but see it on macOS 10.12 and 10.13.
I am making an iOS application in which I am using socket.io. The scenario is very simple, a person books an adventure i.e sending data using emit command. After that, i have used socket.on in order to get the response back from the server. This was working perfectly for sometime but now I am facing problems. Neither the data is reaching the server, nor response is coming back. I searched about this problem and the understanding I got is:
There is some point in which socket is getting disconnected and therefore the it stops working. I even used socket.reconnect before emitting data but it didn't work.
I found a parameter of forceNew for node.js but didn't find any of its alternative in swift.
Here is my code (related to socket.io):
In AppDelegate:
In ViewController:
And the log is:
Even i tried to use socket.on in AppDelegate like this: (as in example from official docs)
But still it didn't work for me.
Update: Sometimes while on emit command, Engine is being closed appears in log but I am not getting any clue how to solve this issue.