[noPoll] noPollOnMessageHandler called with empty message

Andreas Grapentin andreas.grapentin en student.hpi.uni-potsdam.de
Jue Jun 26 18:00:43 CEST 2014


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

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

in my callback.

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

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?

Thank you, and kind Regards,

Below is my main function, and my callback:

botframe_callback (noPollCtx *ctx, noPollConn *conn, noPollMsg *msg,
noPollPtr *user_data)
  if (nopoll_msg_is_fragment(msg))
      printf("oh, I got a fragment!\n");

  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");

  // 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

main (void)
  noPollCtx *ctx = nopoll_ctx_new();
  if (!ctx)
      perror("unable to create websocket context");

  nopoll_ctx_set_on_msg(ctx, (noPollOnMessageHandler)&botframe_callback,

  noPollConn *conn = nopoll_conn_new(ctx, "localhost", "8080", NULL,
  if (!nopoll_conn_is_ok(conn))
      perror("unable to connect to cow server");

  nopoll_loop_wait(ctx, 0);

  return 0;
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://lists.aspl.es/pipermail/nopoll/attachments/20140626/70151887/attachment.html>

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