[Libwebsockets] regarding sending new pending truncated message

Andy Green andy at warmcat.com
Tue Aug 2 19:54:57 CEST 2016

On August 2, 2016 11:30:26 PM GMT+08:00, SUMAN PATRO <suman.patro at somaiya.edu> wrote:
>I have been getting an error as sending new,  pending truncated when I
>1 kb message at a faster rate to the javascript client from my
>When I introduce a sleep of 1 sec..  The error seems to occurs after
>point in time.. I.e the error disappears for some time. I did read the
>solution of flow control.  I have used lws_send_pipe_choked but this
>doesn't resolve the issue. I learnt that the above method needs to be
>in the server_ writable callback,  but my data sending in the server is
>handled using an other method and not server writable. What could be

You evidently already know the answer... only do lws_write() from the WRITEABLE callback.

Instead of doing your write when you feel like it, regardless of the state of the remote peer, change your code to instead ask for a callback when (the remote peer is) writable only.  Do the actual write in the callback.

Then your writes will take place at the slower of when your code wants to do them and the rate the individual peer can accept them, which reflects the best that can be achieved.


More information about the Libwebsockets mailing list