Open michaelochs opened 1 year ago
I am not sure if this is a server side issue or a client side issue but if I connect to my server with socket.io via JavaScript it works, so at a minimum the swift client is behaving different here:
I have a flask-socket.io python server that, in its connect handler emits an 'update_device' event to the client so that the client gets the initial state of everything. The server then subsequently sends 'update_device' events when it encounters updates.
My Swift client is able to receive the subsequent update messages but it fails to receive the initial one. In the logs I can see that this event reaches it but that happens before the connect finishes, which kinda makes sense given that this happens on the server side inside the connect handler.
The JavaScript implementation doesn't seem to have a problem with that, but the Swift implementation does not seem to like this and simply drops that update.
Here's the entire client side log.
LOG SocketIOClient{/device}: Adding handler for event: connect LOG SocketIOClient{/device}: Adding handler for event: device_update LOG SocketIOClient{/device}: Handling event: statusChange with data: [connecting, 2] LOG SocketIOClient{/device}: Joining namespace /device LOG SocketManager: Tried connecting socket when engine isn't open. Connecting LOG SocketManager: Adding engine LOG SocketEngine: Starting engine. Server: http://localhost:8080 LOG SocketEngine: Handshaking LOG SocketEnginePolling: Doing polling GET http://localhost:8080/socket.io/?transport=polling&b64=1&EIO=4 LOG SocketEnginePolling: Got polling response LOG SocketEnginePolling: Got poll message: 0{"sid":"yLEza-oHKIW_iZziAAAC","upgrades":["websocket"],"pingTimeout":20000,"pingInterval":25000} LOG SocketEngine: Got message: 0{"sid":"yLEza-oHKIW_iZziAAAC","upgrades":["websocket"],"pingTimeout":20000,"pingInterval":25000} LOG SocketEnginePolling: Doing polling GET http://localhost:8080/socket.io/?transport=polling&b64=1&EIO=4&sid=yLEza-oHKIW_iZziAAAC LOG SocketManager: Engine opened Connect LOG SocketEngine: Writing poll: 0/device,{"udid":"1"} has data: false LOG SocketEnginePolling: Sending poll: 0/device,{"udid":"1"} as type: 4 LOG SocketEnginePolling: Created POST string: 40/device,{"udid":"1"} LOG SocketEnginePolling: POSTing LOG SocketEnginePolling: Doing polling POST http://localhost:8080/socket.io/?transport=polling&b64=1&EIO=4&sid=yLEza-oHKIW_iZziAAAC LOG SocketEnginePolling: Got polling response LOG SocketEnginePolling: Got poll message: 42/device,["device_update",{"value":5,"message":"My message"}]\^^40/device,{"sid":"cFuzvmNfCD6TKA6EAAAD"} LOG SocketEngine: Got message: 42/device,["device_update",{"value":5,"message":"My message"}] LOG SocketEngine: Got message: 40/device,{"sid":"cFuzvmNfCD6TKA6EAAAD"} LOG SocketParser: Parsing 2/device,["device_update",{"value":5,"message":"My message"}] LOG SocketEnginePolling: Doing polling GET http://localhost:8080/socket.io/?transport=polling&b64=1&EIO=4&sid=yLEza-oHKIW_iZziAAAC LOG SocketParser: Decoded packet as: SocketPacket {type: 2; data: [device_update, { message = "My message"; value = 5; }]; id: -1; placeholders: -1; nsp: /device} LOG SocketParser: Parsing 0/device,{"sid":"cFuzvmNfCD6TKA6EAAAD"} LOG SocketParser: Decoded packet as: SocketPacket {type: 0; data: [{ sid = cFuzvmNfCD6TKA6EAAAD; }]; id: -1; placeholders: -1; nsp: /device} LOG SocketIOClient{/device}: Socket connected LOG SocketIOClient{/device}: Handling event: statusChange with data: [connected, 3] LOG SocketIOClient{/device}: Handling event: connect with data: ["/device", ["sid": cFuzvmNfCD6TKA6EAAAD]] >>> CONNECT HANDLER CALLED unable to parse data: ["/device", ["sid": cFuzvmNfCD6TKA6EAAAD]]
Same for me. Have you resolved this problem?
Yes actually. I managed to get this working my specifying always_connect=True
when initializing the SocketIO server.
I am not sure if this is a server side issue or a client side issue but if I connect to my server with socket.io via JavaScript it works, so at a minimum the swift client is behaving different here:
I have a flask-socket.io python server that, in its connect handler emits an 'update_device' event to the client so that the client gets the initial state of everything. The server then subsequently sends 'update_device' events when it encounters updates.
My Swift client is able to receive the subsequent update messages but it fails to receive the initial one. In the logs I can see that this event reaches it but that happens before the connect finishes, which kinda makes sense given that this happens on the server side inside the connect handler.
The JavaScript implementation doesn't seem to have a problem with that, but the Swift implementation does not seem to like this and simply drops that update.
Here's the entire client side log.