[Libwebsockets] lwsts[14029]: ****** c4f0e0 Sending new, pending truncated ... ??

Fabian Kurz fabian at fkurz.net
Fri Jul 31 09:51:27 CEST 2015


Hi John,

On Wed, Jul 29, 2015 at 12:02:40PM +0200, Sagaert Johan wrote:
> I have a problem in my libwebsockets app.
> 
> In my callback case LWS_CALLBACK_SERVER_WRITEABLE:
> 
> {
>   char texttosend[255];
> 
>   // get (JSON) strings to sent from a fifo queue
>   while(getqueued_item(per_sessie_data->phtml5websocket_client,texttosend))
>   {
>      printf("Sending TO HTML: [%s]\n",texttosend);
>      n = libwebsocket_write(wsi, (unsigned char *) texttosend,strlen(texttosend), LWS_WRITE_TEXT);
>   }
> 
> }

Your send buffer is missing the required padding.

Quote from libwebsocket.h:

/*
 * IMPORTANT NOTICE!
 *
 * When sending with websocket protocol (LWS_WRITE_TEXT or LWS_WRITE_BINARY)
 * the send buffer has to have LWS_SEND_BUFFER_PRE_PADDING bytes valid BEFORE
 * buf, and LWS_SEND_BUFFER_POST_PADDING bytes valid AFTER (buf + * len).
 */

Check the code in test-server.c for an example of how to do the pre and post
padding properly.

HTH,
Fabian

-- 
Fabian Kurz, DJ1YFK      Munich, Germany
fabian at fkurz.net         +49 176 24079617
http://fkurz.net/        http://lcwo.net/



More information about the Libwebsockets mailing list