socket.io-client-csharp icon indicating copy to clipboard operation
socket.io-client-csharp copied to clipboard

Message compression

Open brako opened this issue 1 year ago • 2 comments

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,

brako avatar Dec 06 '24 14:12 brako

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

LevyShang avatar Jan 08 '25 08:01 LevyShang

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.

brako avatar Jan 09 '25 17:01 brako