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

Message compression #393

Open
brako opened this issue Dec 6, 2024 · 2 comments
Open

Message compression #393

brako opened this issue Dec 6, 2024 · 2 comments

Comments

@brako
Copy link

brako commented Dec 6, 2024

Hi,

I want to enable the perMessageDeflate option on my Node.js Socket.IO server to compress messages and reduce bandwidth usage. However, it seems the C# client does not support or acknowledge the compression, while the JavaScript client handles the compressed messages without any problems.

Thanks,

@LevyShang
Copy link

You can try SocketIOOptions.ExtraHeaders,I think it can be like this : ExtraHeaders.add("Sec-WebSocket-Extensions","permessage-deflate; client_max_window_bits")

@brako
Copy link
Author

brako commented Jan 9, 2025

I researched this topic and found the following:

  • Permessage-deflate is not managed by Socket.IO but is a feature of WebSocket clients.
  • The default WebSocket client used by the library (Net Standard ClientWebSocket) does not support the permessage-deflate option.
  • A possible solution is to implement the IClientWebSocket interface and use a different WebSocket client.

Thank you for your suggestion, but unfortunately, it didn’t work. This seems to be expected behavior, as adding the header signals to the server that we can receive compressed data, even though the default WebSocket cannot decompress it. Without the header, the server assumes we cannot decompress and sends uncompressed data, even if data compression is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants