Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binary events sent to handlers have a 0x4 byte prepended to the binary data (v4 server) #277

Closed
kelnos opened this issue Mar 1, 2024 · 2 comments · Fixed by #278 or #281
Closed
Assignees
Labels
bug Something isn't working

Comments

@kelnos
Copy link
Contributor

kelnos commented Mar 1, 2024

Describe the bug

When socketioxide is acting as a v4 server, and a client sends a binary event, the Vec<u8> that is exposed to the handler has a 0x4 byte prepended to the otherwise-correct data.

To Reproduce

See https://github.com/kelnos/socketioxide-binary-test for a reproducer; README contains instructions for running it.

Expected behavior

Binary data should appear in the socketioxide handler as it was sent by the client, not with an extra 0x4 byte in front of the data.

Versions (please complete the following information):

  • Socketioxide version: 0.8.0 or 0.10.2
  • Http lib: warp 0.3 or axum 0.7.4
  • Socket.io client version: Java 1.0.2, JS 2.5.0

Additional context

There are no issues when socketioxide is acting as a v5 server.

@kelnos kelnos added the bug Something isn't working label Mar 1, 2024
@kelnos
Copy link
Contributor Author

kelnos commented Mar 1, 2024

This issue happens only when the client connects using the WebSocket transport. The HTTP polling transport is fine.

@kelnos
Copy link
Contributor Author

kelnos commented Mar 1, 2024

After tracing through the Java socket.io client, I do see that the binary packet encoder prepends a byte for the packet type, which is MESSAGE in this case, which has the value 4. I also dug through the Java socket.io server's code as well as the JS engine.io-parser code, and I see where it parses incoming WS binary frames, and pulls off the first byte as the packet type.

So that seems to be what's happening here. I guess the current EIO version doesn't have that packet type byte at the front of the WS frame, but EIO v3 does? And socketioxide doesn't appear to differentiate?

kelnos added a commit to kelnos/socketioxide that referenced this issue Mar 1, 2024
In v3 of the engine.io protocol, the packet type byte is prepended to
the binary data that is sent out on a websocket binary frame.  This byte
needs to be stripped off the data before it's sent to the handler.

Closes Totodore#277.
kelnos added a commit to kelnos/socketioxide that referenced this issue Mar 1, 2024
In v3 of the engine.io protocol, the packet type byte is prepended to
the binary data that is sent out on a websocket binary frame.  This byte
needs to be stripped off the data before it's sent to the handler.

Closes Totodore#277.
kelnos added a commit to kelnos/socketioxide that referenced this issue Mar 1, 2024
In v3 of the engine.io protocol, the packet type byte is prepended to
the binary data that is sent out on a websocket binary frame.  This byte
needs to be stripped off the data before it's sent to the handler.

Closes Totodore#277.
Totodore pushed a commit that referenced this issue Mar 1, 2024
In v3 of the engine.io protocol, the packet type byte is prepended to
the binary data that is sent out on a websocket binary frame.  This byte
needs to be stripped off the data before it's sent to the handler.

Closes #277.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants