Socket.io-client-swift: Sometimes emit method is not working on connect

Created on 4 Jun 2016  Â·  14Comments  Â·  Source: socketio/socket.io-client-swift

I am emitting an event when socket connects to server. I am using following code to do this

self.socket.on("connect") {data, ack in
print("connected")
socket.emit("hello",variable)
}

I am checking xCode log and I see "connected" text. Then I am checking server, I see the client is connected but "hello" event is not triggered. I am sure with my server, there is no bug.

This is happening randomly, not happening everytime. But for example: If I try to connect to my server for 10 times, this is happening for 2 times. Do you have an idea for this problem?

PS: I always see the "connected" text and connection on server. Problem is "emit" Sometimes it is not emitting to server when connects.

unconfirmed

Most helpful comment

Any updates regarding this?

All 14 comments

Have you turned on logging to see if it it's being sent?

Yes, I can see it on the logs. It's sending.

2016-06-05 2:13 GMT+03:00 Erik Little [email protected]:

Have you turned on logging to see if it it's being sent?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/socketio/socket.io-client-swift/issues/385#issuecomment-223783447,
or mute the thread
https://github.com/notifications/unsubscribe/AAu1FYkjdNmT-mhJzpWYrcSUYW5FFgf9ks5qIgaEgaJpZM4IuOjG
.

Tolgay Toklar
Bursa,Turkey

Have you checked the server with debugging on to see if it's getting it but malformed? I think a malformed packet should cause a disconnect but I'm not sure.

Same issue happened right now. My log:

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: connect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: disconnect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: error

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: reconnectAttempt

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: processmessage

2016-06-06 19:19:35.225 Ribony[1186:498662] Log SocketIOClient: Adding
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Starting
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Handshaking

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Doing polling
request

2016-06-06 19:19:35.648 Ribony[1186:498662] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.651 Ribony[1186:498667] Log SocketEngine: Got message:
0{"sid":"3otwJn3vt0ALcwR9ANAM","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

2016-06-06 19:19:35.653 Ribony[1186:498667] Log SocketEngine: Doing polling
request

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Doing polling
request

2016-06-06 19:19:35.872 Ribony[1186:498667] Log SocketEngine: Got message:
40

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Parsing 0

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Decoded
packet as: SocketPacket {type: 0; data: []; id: -1; placeholders: 0; nsp: /}

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Socket
connected

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Handling
event: connect with data: (

)

Joining room

2016-06-06 19:19:35.880 Ribony[1186:498694] Log SocketIOClient: Emitting:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.880 Ribony[1186:498667] Log SocketEngine: Writing poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
has data: 0

2016-06-06 19:19:35.881 Ribony[1186:498667] Log SocketEngine: Sending poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
as type: 4

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: POSTing:
143:42["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: Doing polling
request

2016-06-06 19:19:36.103 Ribony[1186:498667] Log SocketEngine: Sending ws:
probe as type: 2

2016-06-06 19:19:36.239 Ribony[1186:498694] Log SocketEngine: Got message:
3probe

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Upgrading
transport to WebSockets

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Sending
poll: as type: 6

2016-06-06 19:19:36.344 Ribony[1186:498695] Log SocketEngine: Got polling
response

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Sending ws:
as type: 5

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Flushing
probe wait

2016-06-06 19:19:36.347 Ribony[1186:498694] Log SocketEngine: Got message: 6

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:00.827 Ribony[1186:498695] Log SocketEngine: Got message: 3

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:25.865 Ribony[1186:498884] Log SocketEngine: Got message: 3

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:51.335 Ribony[1186:498946] Log SocketEngine: Got message: 3

2016-06-06 19:21:15.655 Ribony[1186:499024] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:21:15.656 Ribony[1186:499024] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:21:15.801 Ribony[1186:499024] Log SocketEngine: Got message: 3

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:21:40.868 Ribony[1186:499107] Log SocketEngine: Got message: 3

2016-06-06 19:18 GMT+03:00 Tolgay Toklar [email protected]:

Yes, I can see it on the logs. It's sending.

2016-06-05 2:13 GMT+03:00 Erik Little [email protected]:

Have you turned on logging to see if it it's being sent?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/socketio/socket.io-client-swift/issues/385#issuecomment-223783447,
or mute the thread
https://github.com/notifications/unsubscribe/AAu1FYkjdNmT-mhJzpWYrcSUYW5FFgf9ks5qIgaEgaJpZM4IuOjG
.

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

One more thing: When this problem happens, there is no problem with
connection because i can sending message.

2016-06-06 19:23 GMT+03:00 Tolgay Toklar [email protected]:

Same issue happened right now. My log:

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: connect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: disconnect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: error

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: reconnectAttempt

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: processmessage

2016-06-06 19:19:35.225 Ribony[1186:498662] Log SocketIOClient: Adding
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Starting
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Handshaking

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.648 Ribony[1186:498662] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.651 Ribony[1186:498667] Log SocketEngine: Got message:
0{"sid":"3otwJn3vt0ALcwR9ANAM","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

2016-06-06 19:19:35.653 Ribony[1186:498667] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.872 Ribony[1186:498667] Log SocketEngine: Got message:
40

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Parsing 0

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Decoded
packet as: SocketPacket {type: 0; data: []; id: -1; placeholders: 0; nsp: /}

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Socket
connected

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Handling
event: connect with data: (

)

Joining room

2016-06-06 19:19:35.880 Ribony[1186:498694] Log SocketIOClient: Emitting:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.880 Ribony[1186:498667] Log SocketEngine: Writing
poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
has data: 0

2016-06-06 19:19:35.881 Ribony[1186:498667] Log SocketEngine: Sending
poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
as type: 4

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: POSTing:
143:42["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: Doing
polling request

2016-06-06 19:19:36.103 Ribony[1186:498667] Log SocketEngine: Sending ws:
probe as type: 2

2016-06-06 19:19:36.239 Ribony[1186:498694] Log SocketEngine: Got message:
3probe

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Upgrading
transport to WebSockets

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Sending
poll: as type: 6

2016-06-06 19:19:36.344 Ribony[1186:498695] Log SocketEngine: Got polling
response

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Sending ws:
as type: 5

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Flushing
probe wait

2016-06-06 19:19:36.347 Ribony[1186:498694] Log SocketEngine: Got message:
6

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:00.827 Ribony[1186:498695] Log SocketEngine: Got message:
3

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:25.865 Ribony[1186:498884] Log SocketEngine: Got message:
3

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:20:51.335 Ribony[1186:498946] Log SocketEngine: Got message:
3

2016-06-06 19:21:15.655 Ribony[1186:499024] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:21:15.656 Ribony[1186:499024] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:21:15.801 Ribony[1186:499024] Log SocketEngine: Got message:
3

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Writing ws:
has data: 0

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Sending ws:
as type: 2

2016-06-06 19:21:40.868 Ribony[1186:499107] Log SocketEngine: Got message:
3

2016-06-06 19:18 GMT+03:00 Tolgay Toklar [email protected]:

Yes, I can see it on the logs. It's sending.

2016-06-05 2:13 GMT+03:00 Erik Little [email protected]:

Have you turned on logging to see if it it's being sent?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/socketio/socket.io-client-swift/issues/385#issuecomment-223783447,
or mute the thread
https://github.com/notifications/unsubscribe/AAu1FYkjdNmT-mhJzpWYrcSUYW5FFgf9ks5qIgaEgaJpZM4IuOjG
.

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

Sorry for, emails. I think i found the problem. When this happens I see
"flushing proble wait" log message on logs. What is this?

2016-06-06 19:25 GMT+03:00 Tolgay Toklar [email protected]:

One more thing: When this problem happens, there is no problem with
connection because i can sending message.

2016-06-06 19:23 GMT+03:00 Tolgay Toklar [email protected]:

Same issue happened right now. My log:

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: connect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: disconnect

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: error

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: reconnectAttempt

2016-06-06 19:19:35.224 Ribony[1186:498662] Log SocketIOClient: Adding
handler for event: processmessage

2016-06-06 19:19:35.225 Ribony[1186:498662] Log SocketIOClient: Adding
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Starting
engine

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Handshaking

2016-06-06 19:19:35.226 Ribony[1186:498662] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.648 Ribony[1186:498662] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.651 Ribony[1186:498667] Log SocketEngine: Got
message:
0{"sid":"3otwJn3vt0ALcwR9ANAM","upgrades":["websocket"],"pingInterval":25000,"pingTimeout":60000}

2016-06-06 19:19:35.653 Ribony[1186:498667] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Got polling
response

2016-06-06 19:19:35.868 Ribony[1186:498664] Log SocketEngine: Doing
polling request

2016-06-06 19:19:35.872 Ribony[1186:498667] Log SocketEngine: Got
message: 40

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Parsing 0

2016-06-06 19:19:35.875 Ribony[1186:498623] Log SocketParser: Decoded
packet as: SocketPacket {type: 0; data: []; id: -1; placeholders: 0; nsp: /}

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Socket
connected

2016-06-06 19:19:35.876 Ribony[1186:498623] Log SocketIOClient: Handling
event: connect with data: (

)

Joining room

2016-06-06 19:19:35.880 Ribony[1186:498694] Log SocketIOClient: Emitting:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.880 Ribony[1186:498667] Log SocketEngine: Writing
poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
has data: 0

2016-06-06 19:19:35.881 Ribony[1186:498667] Log SocketEngine: Sending
poll:
2["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]
as type: 4

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: POSTing:
143:42["joinToRoom",{"Chtoken":"074dd49f4110a2667683050dccd0b6ae","UserPass":"1","Username":"tolgay007","AnonId":"anony-b9f57f4cd9f3bfe","newA":1}]

2016-06-06 19:19:35.882 Ribony[1186:498667] Log SocketEngine: Doing
polling request

2016-06-06 19:19:36.103 Ribony[1186:498667] Log SocketEngine: Sending ws:
probe as type: 2

2016-06-06 19:19:36.239 Ribony[1186:498694] Log SocketEngine: Got
message: 3probe

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Upgrading
transport to WebSockets

2016-06-06 19:19:36.240 Ribony[1186:498694] Log SocketEngine: Sending
poll: as type: 6

2016-06-06 19:19:36.344 Ribony[1186:498695] Log SocketEngine: Got polling
response

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Sending
ws: as type: 5

2016-06-06 19:19:36.345 Ribony[1186:498695] Log SocketEngine: Flushing
probe wait

2016-06-06 19:19:36.347 Ribony[1186:498694] Log SocketEngine: Got
message: 6

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Writing
ws: has data: 0

2016-06-06 19:20:00.655 Ribony[1186:498695] Log SocketEngine: Sending
ws: as type: 2

2016-06-06 19:20:00.827 Ribony[1186:498695] Log SocketEngine: Got
message: 3

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Writing
ws: has data: 0

2016-06-06 19:20:25.655 Ribony[1186:498884] Log SocketEngine: Sending
ws: as type: 2

2016-06-06 19:20:25.865 Ribony[1186:498884] Log SocketEngine: Got
message: 3

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Writing
ws: has data: 0

2016-06-06 19:20:50.655 Ribony[1186:498946] Log SocketEngine: Sending
ws: as type: 2

2016-06-06 19:20:51.335 Ribony[1186:498946] Log SocketEngine: Got
message: 3

2016-06-06 19:21:15.655 Ribony[1186:499024] Log SocketEngine: Writing
ws: has data: 0

2016-06-06 19:21:15.656 Ribony[1186:499024] Log SocketEngine: Sending
ws: as type: 2

2016-06-06 19:21:15.801 Ribony[1186:499024] Log SocketEngine: Got
message: 3

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Writing
ws: has data: 0

2016-06-06 19:21:40.655 Ribony[1186:499107] Log SocketEngine: Sending
ws: as type: 2

2016-06-06 19:21:40.868 Ribony[1186:499107] Log SocketEngine: Got
message: 3

2016-06-06 19:18 GMT+03:00 Tolgay Toklar [email protected]:

Yes, I can see it on the logs. It's sending.

2016-06-05 2:13 GMT+03:00 Erik Little [email protected]:

Have you turned on logging to see if it it's being sent?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/socketio/socket.io-client-swift/issues/385#issuecomment-223783447,
or mute the thread
https://github.com/notifications/unsubscribe/AAu1FYkjdNmT-mhJzpWYrcSUYW5FFgf9ks5qIgaEgaJpZM4IuOjG
.

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

Tolgay Toklar
Bursa,Turkey

Flushing probe wait is because during the upgrade process from polling to websockets I found that trying to do anymore polling would cause a disconnect. So during that upgrade time it buffers until it finishes upgrading.

I'm finding the same behavior with the current version of the client (8.2.0) + server (1.7.2), but I haven't checked the logs to see if I'm getting the same errors. Is this a potential bug, or is there a way to detect that emits aren't being sent yet?

I think I see an issue in SocketEngine.swift. The write() method has a case which does

self.probeWait.append((msg, type, data))

but in flushProbeWait() the code does

 for waiter in probeWait {
    write(waiter.msg, withType: waiter.type, withData: waiter.data)
 }
 probeWait.removeAll(keepingCapacity: false)

which results in deleting the waiters. Is this intended?

public func write(_ msg: String, withType type: SocketEnginePacketType, withData data: [Data]) {

  | engineQueue.async {
  | guard self.connected else { return }
  |  
  | if self.websocket {
  | DefaultSocketLogger.Logger.log("Writing ws: %@ has data: %@",
  | type: self.logType, args: msg, data.count != 0)
  | self.sendWebSocketMessage(msg, withType: type, withData: data)
  | } else if !self.probing {
  | DefaultSocketLogger.Logger.log("Writing poll: %@ has data: %@",
  | type: self.logType, args: msg, data.count != 0)
  | self.sendPollMessage(msg, withType: type, withData: data)
  | } else {
  | self.probeWait.append((msg, type, data))
  | }
  | }
  | }
 

private func flushProbeWait() {

  | DefaultSocketLogger.Logger.log("Flushing probe wait", type: logType)
  |  
  | for waiter in probeWait {
  | write(waiter.msg, withType: waiter.type, withData: waiter.data)
  | }
  |  
  | probeWait.removeAll(keepingCapacity: false)
  |  
  | if postWait.count != 0 {
  | flushWaitingForPostToWebSocket()
  | }
  | }
 

Hm maybe. flushProbeWait should be called after a switch to websockets. But maybe there's some case where it adds to probeWait after flushing.

I have an intermittent issue where an emit call in "onConnect" is basically ignored, i.e.

socket!.on("connect") {data, ack in
socket.emit("authenticate", obj)
}

I observed in the logs that the emit message was queued but no POST operation occurred. I also observed that flushProbeWait is called from WebSocket.swift doDisconnect() shortly after connecting, before upgrading. I haven't been able to demonstrated it decisively, but I suspect that the flush operation deleted the message.

That would be this path https://github.com/socketio/socket.io-client-swift/blob/master/Source/SocketIO/Engine/SocketEngine.swift#L637. Which would mean that the socket failed to upgrade... This isn't a path I test regularly since it's difficult to trigger. It would be interesting to know the state of the engine at that moment.

Any updates regarding this?

Hello, I'm facing this issue, any solution regarding this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leeyuno picture leeyuno  Â·  5Comments

MD04-TanTan picture MD04-TanTan  Â·  5Comments

matthiasp42 picture matthiasp42  Â·  3Comments

alionthego picture alionthego  Â·  4Comments

harshanakaru picture harshanakaru  Â·  4Comments