[noPoll] noPollOnMessageHandler called with empty message
Andreas Grapentin
andreas.grapentin en student.hpi.uni-potsdam.de
Dom Jul 6 19:44:37 CEST 2014
Hi again,
Sorry for the delay. strlen on the message payload buffer returns 0.
I think my websockets setup is quite unusal, and I will try to clarify a
bit.
I have a server application witten in node.js, and connect a number of
websocket clients written in various languages to that server. One of
these clients is written in C and uses the nopoll library. The others
are written in java, php, python and javascript, again node.js. No
browsers involved.
This is the point where we break up the client/server model, because the
connected clients will now listen for messages from the server. The
server implements a round-based simulation, and will send a message for
each round to the clients, and wait for their replies, basically
implementing a broadcast and barrier pattern.
at some point during the simulation, the C client (and only the C
client) fails because the messages it receives stop making sense,
starting with an empty message followed by several messages marked as
fragments.
The other clients do not show this behaviour, which makes me think the
error must be somewhere within the library (or I use it wrong).
I will try again with the latest version from the repository, and if it
still persists I will try to find the source of the problem.
If I find out anything interesting, I'll let you know.
kind Regards,
Andreas
P.S: please tell me if this mailing list is using bottom-posting instead
of top-posting =)
On 06/29/2014 05:26 PM, Francis Brosnan Blázquez wrote:
> 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 <mailto: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/20140706/04aefbff/attachment.html>
Más información sobre la lista de distribución noPoll