Help to port Socket.IO to Emscripten (WebAssembly) #5251
-
I am creating a Socket.IO implementation for Emscripten in C++, purely using WebSockets. I followed the documentation for several days and even tried reverse-engineering the client for web browsers, but without success. Below is a step-by-step description of what I am doing, and I would be very grateful to know what I did wrong to experience frequent disconnections. WebSocket URL I connect and I receive
Then I anwser with
Then the connection keeps for while... If I try to send
I got disconnected immediately. Also, if I receive
And anwser with
I got disconnected immediately too. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi! The protocol is split in two:
Reference: https://socket.io/docs/v4/engine-io-protocol/
Every Socket.IO packet must be prefixed by So sending a CONNECT packet ( Then you will be able to send message with Reference: https://socket.io/docs/v4/socket-io-protocol/#format |
Beta Was this translation helpful? Give feedback.
-
I see. Thank you! |
Beta Was this translation helpful? Give feedback.
Hi!
The protocol is split in two:
0{"sid":"w4Nlz...}
is the handshake sent by the server2
are indeed PING packets, and the client should respond with a PONG packet (3
)Reference: https://socket.io/docs/v4/engine-io-protocol/
Every Socket.IO packet must be prefixed by
4
, indicating an Engine.IO MESSAGE packet.So sending a CONNECT packet (
0
) becomes a40
over the wire.Then you will be able to send message with
42[...]
.Reference: https://socket.io/docs/v4/socket-io-protocol/#format