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

Adapter not supporting binary data #10

Closed
tmotagam opened this issue Jan 18, 2023 · 2 comments
Closed

Adapter not supporting binary data #10

tmotagam opened this issue Jan 18, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@tmotagam
Copy link

Hi,
I am trying to send binary data UInt8Array the data is going from client to server properly but when the server broadcast the received data the other server in the cluster is not receiving the data it receives this.

{ placeholder: true, num: 0 }

when I see the mongodb collection also shows what I receives on the receiving client.
Also the client on the receiving end disconnects once this malformed data starts to come in

socket.io server version: 4.5.4
socket.io client version: 4.5.4
nodejs: 18.0
os: windows
mongodb: 5

@darrachequesne
Copy link
Member

Hi! I could indeed reproduce with the latest mongodb version, I'm digging into this.

darrachequesne added a commit to socketio/socket.io-parser that referenced this issue Jan 19, 2023
Note: this issue has existed since Socket.IO v1.0 (see [1]), because
the `deconstructPacket()` method also mutates its input argument.

This also explains why some adapters (like [2]) need to use
`process.nextTick()` when extending the `broadcast()` method, because
`Adapter.broadcast()` calls `Encoder.encode()` ([3]).

Related:

- socketio/socket.io#4374
- socketio/socket.io-mongo-adapter#10

[1]: 299849b
[2]: https://github.com/socketio/socket.io-postgres-adapter/blob/0.3.0/lib/index.ts#L587-L590
[3]: https://github.com/socketio/socket.io-adapter/blob/2.4.0/lib/index.ts#L148
darrachequesne added a commit that referenced this issue Jan 19, 2023
- the types are now included in the `mongodb` package
- the "promoteBuffers" option now works properly
- the "useUnifiedTopology" option was removed

Reference: https://github.com/mongodb/node-mongodb-native/blob/main/etc/notes/CHANGES_4.0.0.md

Related:

- #10
- socketio/socket.io-parser@ae8dd88
@darrachequesne
Copy link
Member

OK, so I think I have found the culprit, this should be fixed by socketio/socket.io-parser@ae8dd88, included in [email protected].

I've also added a test here: ea20cce

Thanks a lot for the clear report 👍

Please reopen if needed!

@darrachequesne darrachequesne added the bug Something isn't working label Jan 19, 2023
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
Development

No branches or pull requests

2 participants