<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Hi again,<br>
<br>
Sorry for the delay. strlen on the message payload buffer returns
0.<br>
<br>
I think my websockets setup is quite unusal, and I will try to
clarify a bit.<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
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).<br>
<br>
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.<br>
<br>
If I find out anything interesting, I'll let you know.<br>
<br>
kind Regards,<br>
Andreas<br>
<br>
P.S: please tell me if this mailing list is using bottom-posting
instead of top-posting =)<br>
<br>
<br>
On 06/29/2014 05:26 PM, Francis Brosnan Blázquez wrote:<br>
</div>
<blockquote cite="mid:1404055561.23080.40.camel@blaster.aspl.es"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="GENERATOR" content="GtkHTML/4.2.2">
On jue, 2014-06-26 at 18:00 +0200, Andreas Grapentin wrote:<br>
<blockquote type="CITE"> Hi,<br>
</blockquote>
<br>
Hi there Andreas,<br>
<br>
<blockquote type="CITE"> first of all, thank you very much for
giving the world a decent WebSockets library in C. That made my
life so much easier!<br>
</blockquote>
<br>
;-) Thank you very much for your words. That means a lot to us! A
twitter pat won't hurt @aspl_es :-)<br>
<br>
<blockquote type="CITE"> Unfortunately though, there seems to be a
glitch where after a couple of seconds of continuous runtime a
frame arrives at my program, where<br>
<br>
nopoll_msg_get_payload(msg); // returns an empty string<br>
nopoll_msg_get_payload_size(msg); // returns 1<br>
</blockquote>
<br>
Interesting.... so calling to strlen over the result reported by
nopoll_msg_get_payload reports 0 or 1?<br>
<br>
<blockquote type="CITE"> in my callback.<br>
<br>
If I choose to silently ignore this event, then the following
frames are corrupted, reporting invalid data.<br>
</blockquote>
<br>
Uhmn.... so something gets tangled there :-?<br>
<br>
<blockquote type="CITE"> This usually happens only when my app is
on very high traffic, and has run for about a minute.<br>
<br>
Can you help me find out what's going wrong, or point me in the
right direction where to look?<br>
</blockquote>
<br>
Don't know... yet ;-). We have it working for several public
available products and nothing similar has been reported...<br>
...and one of them is very traffic intense (Core-Admin).<br>
<br>
You can try the following:<br>
<br>
1) In the case you are using a browser, try to upgrade it.
WebSocket is a fairly young protocol. We have found<br>
various issues with some browsers that got fixed after upgrading
them.<br>
<br>
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:<br>
<br>
<a moz-do-not-send="true"
href="https://dolphin.aspl.es/svn/publico/nopoll//trunk/">https://dolphin.aspl.es/svn/publico/nopoll//trunk/</a><br>
<br>
3) You can also try running your server with logs enabled and send
us log traces. For that you can<br>
start your server with something like this (assuming you are
running Linux/Unix version):<br>
<br>
>> NOPOLL_DEBUG=1 ./your-server-app<br>
<br>
...and if you are running on windows, you can use a combination of
nopoll_log_enable and nopoll_log_set_handler<br>
to capture the log.<br>
<br>
4) If it doesn't work, please, let us know which browser/client
side software are you using. If would be really great<br>
to have a working example that reproduces the problem...<br>
<br>
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...<br>
<br>
Best Regards,<br>
<br>
<br>
<blockquote type="CITE"> Thank you, and kind Regards,<br>
Andreas<br>
<br>
<br>
Below is my main function, and my callback:<br>
<br>
void<br>
botframe_callback (noPollCtx *ctx, noPollConn *conn, noPollMsg
*msg, noPollPtr *user_data)<br>
{<br>
if (nopoll_msg_is_fragment(msg))<br>
{<br>
printf("oh, I got a fragment!\n");<br>
return;<br>
}<br>
<br>
char *message = nopoll_msg_get_payload(msg);<br>
unsigned int length = nopoll_msg_get_payload_size(msg);<br>
<br>
if (length <= 1)<br>
{<br>
printf("that's not a message!\n");<br>
return;<br>
}<br>
<br>
// after this point, there is a lot of json parsing, and data
management<br>
// somewhere in the middle of it, I send a response:<br>
<br>
nopoll_conn_send_text (conn, str, strlen(str));<br>
<br>
// and then there is some more stuff, and resource releasing
code<br>
}<br>
<br>
<br>
int<br>
main (void)<br>
{<br>
noPollCtx *ctx = nopoll_ctx_new();<br>
if (!ctx)<br>
{<br>
perror("unable to create websocket context");<br>
exit(1);<br>
}<br>
<br>
nopoll_ctx_set_on_msg(ctx,
(noPollOnMessageHandler)&botframe_callback, NULL);<br>
<br>
noPollConn *conn = nopoll_conn_new(ctx, "localhost", "8080",
NULL, NULL, NULL, NULL);<br>
if (!nopoll_conn_is_ok(conn))<br>
{<br>
perror("unable to connect to cow server");<br>
exit(1);<br>
}<br>
<br>
nopoll_loop_wait(ctx, 0);<br>
<br>
return 0;<br>
}
<pre>_______________________________________________
noPoll mailing list
<a moz-do-not-send="true" href="mailto:noPoll@lists.aspl.es">noPoll@lists.aspl.es</a>
<a moz-do-not-send="true" href="http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll">http://lists.aspl.es/cgi-bin/mailman/listinfo/nopoll</a>
</pre>
</blockquote>
<br>
</blockquote>
<br>
</body>
</html>