[Libwebsockets] Receiving large message from WebSocket

Ivan Kolesnikov kiv.apple at gmail.com
Fri Jul 30 21:03:46 CEST 2021


Sometimes I am sending from the server to the client large messages via
WebSocket - up to 16 KB. The problem is that the client is receiving a
message by 1 KB chunks, so I am getting invalid messages. I tried to set a
large rx_buffer_size for my protocol (e. g. 64 KB), but nothing changed.

Is it possible to allow the WebSocket client to buffer the whole message
before passing it to my callback? The client has only one connection to the
server at one time and is not supposed to be launched on embedded
platforms, so it is fine to have buffers with size of hundreds of kilobytes.

Or the other way - how to determine in the protocol callback when a message
started and finished to assemble it from chunks on my own. For now I am
handling LWS_CALLBACK_CLIENT_RECEIVE and just take in and len arguments.

Also I am using the permessage-deflate extension to reduce network load.
Maybe it affects something.

Best regards,
Ivan Kolesnikov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://libwebsockets.org/pipermail/libwebsockets/attachments/20210730/d5840a8e/attachment.htm>

More information about the Libwebsockets mailing list