Closed iJasonWade closed 2 years ago
Not seeing socketparser logs is indicative of something blocking the handleQueue
Here is the queue I run it on:
let backgroundDRSQueue = DispatchQueue.global(qos: .userInitiated)
Why would it work the first 3-5 times I run it and then just stop working?
You should only use serial queues for the client. Otherwise you’ll likely run into race issues. But I don’t know why that would block it up.
Ok, I will switch out my queue and test it, thanks for your help, I'll update this thread with what I find.
So I switched my queue to:
let backgroundDRSQueue = DispatchQueue(label: "drs_queue", qos: .utility)
However, after 2 successful connections the next time I ran my code and it went to connect I had the same issue:
Manager Status : notConnected
addHandlers()
LOG SocketIOClient{/}: Adding handler for event: connect
LOG SocketIOClient{/}: Adding handler for event: statusChange
LOG SocketIOClient{/}: Adding handler for event: error
LOG SocketIOClient{/}: Adding handler for event: corpCon-*************************
LOG SocketIOClient{/}: Adding handler for event: callhistory-*************************
LOG SocketIOClient{/}: Adding handler for event: google-*************************
LOG SocketIOClient{/}: Adding handler for event: disconnect
LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
Status Changed : [connecting]
LOG SocketIOClient{/}: Joining namespace /
LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
LOG SocketManager: Adding engine
LOG SocketEngine: Starting engine. Server: *************************
LOG SocketEngine: Handshaking
LOG SocketEngine: Got message: 0{"sid":"*************************","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
LOG SocketEngine: Writing ws: has data: false
LOG SocketEngineWebSocket: Sending ws: as type: 2
LOG SocketIOClient{/}: Handling event: ping with data: []
LOG SocketManager: Engine opened Connect
LOG SocketIOClient{/}: Socket connected
LOG SocketIOClient{/}: Handling event: statusChange with data: [connected]
Status Changed : [connected]
LOG SocketIOClient{/}: Handling event: connect with data: ["/"]
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}]
LOG SocketEngine: Writing ws: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}] has data: false
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken":"*************************"}]
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}] as type: 4
LOG SocketEngine: Writing ws: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken":"*************************"}] has data: false
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken":"*************************"}] as type: 4
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}]
LOG SocketEngine: Writing ws: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}] has data: false
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}] as type: 4
LOG SocketEngine: Got message: 3
LOG SocketIOClient{/}: Handling event: pong with data: []
LOG SocketEngine: Writing ws: has data: false
LOG SocketIOClient{/}: Handling event: ping with data: []
The asterisks are where I had to redact some sensitive info.
So if I comment out the path in my manager's config and paste the path to the end of the url for the manager it obviously won't connect but I did that because once I change the code back it connects the next time, every time I do that.
Here is my successful connection, same code as when it wasn't connecting above:
Manager Status : notConnected
addHandlers()
LOG SocketIOClient{/}: Adding handler for event: connect
LOG SocketIOClient{/}: Adding handler for event: statusChange
LOG SocketIOClient{/}: Adding handler for event: error
LOG SocketIOClient{/}: Adding handler for event: corpCon-*************************
LOG SocketIOClient{/}: Adding handler for event: callhistory-*************************
LOG SocketIOClient{/}: Adding handler for event: google-*************************
LOG SocketIOClient{/}: Adding handler for event: disconnect
LOG SocketIOClient{/}: Handling event: statusChange with data: [connecting]
Status Changed : [connecting]
LOG SocketIOClient{/}: Joining namespace /
LOG SocketManager: Tried connecting socket when engine isn't open. Connecting
LOG SocketManager: Adding engine
LOG SocketEngine: Starting engine. Server: *************************
LOG SocketEngine: Handshaking
LOG SocketEngine: Got message: 0{"sid":"*************************","upgrades":[],"pingInterval":25000,"pingTimeout":60000}
LOG SocketEngine: Writing ws: has data: false
LOG SocketEngineWebSocket: Sending ws: as type: 2
LOG SocketEngine: Got message: 40
LOG SocketIOClient{/}: Handling event: ping with data: []
LOG SocketManager: Engine opened Connect
LOG SocketIOClient{/}: Socket connected
LOG SocketIOClient{/}: Handling event: statusChange with data: [connected]
Status Changed : [connected]
LOG SocketIOClient{/}: Handling event: connect with data: ["/"]
LOG SocketEngine: Got message: 42["successful_connection",{"socketId":"*************************"}]
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}]
LOG SocketEngine: Writing ws: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}] has data: false
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken":"*************************"}]
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"corpCon","lastUpdate":1515013327,"accessToken":"*************************"}] as type: 4
LOG SocketEngine: Writing ws: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken”:”*************************”}] has data: false
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"callhistory","lastUpdate":1515013327,"accessToken":"*************************"}] as type: 4
LOG SocketIOClient{/}: Emitting: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}]
LOG SocketEngine: Writing ws: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}] has data: false
LOG SocketParser: Parsing 0
LOG SocketEngineWebSocket: Sending ws: 2["join_room",{"type":"google","lastUpdate":0,"accessToken":"*************************"}] as type: 4
LOG SocketParser: Decoded packet as: SocketPacket {type: 0; data: []; id: -1; placeholders: 0; nsp: /}
LOG SocketParser: Parsing 2["successful_connection",{"socketId":"*************************"}]
LOG SocketParser: Decoded packet as: SocketPacket {type: 2; data: [successful_connection, {
socketId = *************************;
}]; id: -1; placeholders: -1; nsp: /}
LOG SocketIOClient{/}: Handling event: successful_connection with data: [{
socketId = *************************;
}]
LOG SocketEngine: Got message: 3
LOG SocketIOClient{/}: Handling event: pong with data: []
LOG SocketEngine: Got message: 42["google-*************************",{"id":"google-*************************","user":"2410","domain":"*************************","emailAddress":"*************************","lastUpdate":1513690802,"type":"googleAccount","eventName":"google-*************************"}]
LOG SocketParser: Parsing 2["google-*************************",{"id":"google-*************************","user":"2410","domain":"*************************","emailAddress":"*************************","lastUpdate":1513690802,"type":"googleAccount","eventName":"google-*************************"}]
I would double check that you're using your API correctly. Because from your first log, even the engine isn't getting anything back.
I'm not sure what you mean because in the first log I can see where the engine did get something back:
SocketEngine: Got message: 42["successful_connection",{"socketId":"*************************"}]
It also gets:
LOG SocketEngine: Got message: 3
And if I wasn't using it correctly then why would it connect the first 3~5 times I run it?
LOG SocketEngine: Got message: 3
Is just a socket.io ping message, which means the client is still actually connected to the server.
I don't see the
SocketEngine: Got message: 42["successful_connection",{"socketId":"*************************"}]
in the first log.
But if you're getting ping/pong that means the actual connection is fine, but something is not right with the logic beyond that. I would double check that the server is actually receiving the messages.
This code was working perfectly when I was using your 11.0.0 release, I didn't face any issues until I migrated to Swift 4 and updated to your latest release
@nuclearace, I have also noticed that when I call disconnect() on the manager, then connect() again when the app comes back into the background I start seeing a new message added, i.e., I ran that scenario 5 times and this is what I saw:
Status Changed : [connected]
Status Changed : [connected]
Status Changed : [connected]
Status Changed : [connected]
Status Changed : [connected]
That was logged out against the "statusChange" .on listener I have.
I also notice it calls my "disconnect" event 5 times when I disconnect again...
Status Changed : [disconnected]
Status Changed : [disconnected]
Status Changed : [disconnected]
Status Changed : [disconnected]
Status Changed : [disconnected]
@iJasonWade Hm, I'm not sure. Going to need a sample project that reproduces the issue. Or debug it yourself.
So after my client connects to my server multiple times successfully all of a sudden it will no longer connect, the missing piece I see from my logs is that any logs from SocketParser are missing such as:
I followed your 12 to 13 FAQ's to make sure I was following what was in there. We do not use a namespace but have a custom path that is a secure connection, here is my config:
The manager is the only strong reference I have but this code is inside of a singleton class, not sure if that makes a difference. We also use the emit() method to subscribe to channels.