[noPoll] noPollOnMessageHandler called with empty message

Francis Brosnan Blázquez francis en aspl.es
Dom Jun 29 17:26:01 CEST 2014


On jue, 2014-06-26 at 18:00 +0200, Andreas Grapentin wrote:

> Hi,


Hi there Andreas,


> first of all, thank you very much for giving the world a decent
> WebSockets library in C. That made my life so much easier!


;-) Thank you very much for your words. That means a lot to us!  A
twitter pat won't hurt @aspl_es :-)


> Unfortunately though, there seems to be a glitch where after a couple
> of seconds of continuous runtime a frame arrives at my program, where
> 
> nopoll_msg_get_payload(msg); // returns an empty string
> nopoll_msg_get_payload_size(msg); // returns 1


Interesting.... so calling to strlen over the result reported by
nopoll_msg_get_payload reports 0 or 1?


> in my callback.
> 
> If I choose to silently ignore this event, then the following frames
> are corrupted, reporting invalid data.


Uhmn.... so something gets tangled there :-?


> This usually happens only when my app is on very high traffic, and has
> run for about a minute.
> 
> Can you help me find out what's going wrong, or point me in the right
> direction where to look?


Don't know... yet ;-). We have it working for several public available
products and nothing similar has been reported...
...and one of them is very traffic intense (Core-Admin).

You can try the following:

1) In the case you are using a browser, try to upgrade it. WebSocket is
a fairly young protocol. We have found
various issues with some browsers that got fixed after upgrading them.

2) You can also have the latest noPoll version from the svn. It is
stable and should be released soon and the next stable release:

https://dolphin.aspl.es/svn/publico/nopoll//trunk/

3) You can also try running your server with logs enabled and send us
log traces. For that you can
start your server with something like this (assuming you are running
Linux/Unix version):

>> NOPOLL_DEBUG=1 ./your-server-app

...and if you are running on windows, you can use a combination of
nopoll_log_enable and nopoll_log_set_handler
to capture the log.

4) If it doesn't work, please, let us know which browser/client side
software are you using. If would be really great
to have a working example that reproduces the problem...

In any case, please let us know your progress to find out if this is
something specific to noPoll or maybe a browser/client side...

Best Regards,



> Thank you, and kind Regards,
> Andreas
> 
> 
> Below is my main function, and my callback:
> 
> void
> botframe_callback (noPollCtx *ctx, noPollConn *conn, noPollMsg *msg,
> noPollPtr *user_data)
> {
>   if (nopoll_msg_is_fragment(msg))
>     {
>       printf("oh, I got a fragment!\n");
>       return;
>     }
> 
>   char *message = nopoll_msg_get_payload(msg);
>   unsigned int length = nopoll_msg_get_payload_size(msg);
> 
>   if (length <= 1)
>     {
>       printf("that's not a message!\n");
>       return;
>     }
> 
>   // after this point, there is a lot of json parsing, and data
> management
>   // somewhere in the middle of it, I send a response:
>  
>       nopoll_conn_send_text (conn, str, strlen(str));
> 
>   // and then there is some more stuff, and resource releasing code
> }
> 
> 
> int
> main (void)
> {
>   noPollCtx *ctx = nopoll_ctx_new();
>   if (!ctx)
>     {
>       perror("unable to create websocket context");
>       exit(1);
>     }
> 
>   nopoll_ctx_set_on_msg(ctx,
> (noPollOnMessageHandler)&botframe_callback, NULL);
> 
>   noPollConn *conn = nopoll_conn_new(ctx, "localhost", "8080", NULL,
> NULL, NULL, NULL);
>   if (!nopoll_conn_is_ok(conn))
>     {
>       perror("unable to connect to cow server");
>       exit(1);
>     }
> 
>   nopoll_loop_wait(ctx, 0);
> 
>   return 0;
> }
> 
> _______________________________________________
> noPoll mailing list
> noPoll en lists.aspl.es
> http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll


------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20140629/056554b2/attachment.html>


Más información sobre la lista de distribución noPoll