ASPLes / nopoll

OpenSource WebSocket toolkit
http://www.aspl.es/nopoll
GNU Lesser General Public License v2.1
124 stars 74 forks source link

nopoll_conn_send_ping or receiving a pong corrupts the connection. #5

Closed dsbaha closed 8 years ago

dsbaha commented 8 years ago

Hi everyone, I'm using the Espressif Version of LibNoPoll located at https://github.com/espressif/ESP8266_RTOS_SDK as well as trunk rev 238 of LibNoPoll from the dolphin site.

The connection establishes fine, I can send text messages back and forth without a problem. However, whenever a ping/pong message comes through the connection goes haywire.

[91330] Starting Websocket Client Task on Socket 2 [93177] Message Received OpCode: 1 Message: asdf [93437] Message Received OpCode: 1 Message: asdf [94277] Message Received OpCode: 1 Message: ping Sending Ping ... (NOTE: The following is just "asdf" being received from the client) [95567] Message Received OpCode: 13 Message: ▒▒▒▒▒t [96416] Message Received OpCode: 0 Message: 0j▒0▒▒fT▒ [96856] Message Received OpCode: 0 Message: [97306] Message Received OpCode: 0 Message: 0j4▒xU▒t

After the ping/pong all further communication is just corrupted from the server view. Having fiddler on the client, it shows correct websocket communication to the server.

` Here is what my RTOS While Loop Looks like;

while(nopoll_conn_is_ok(conn)) {

vTaskDelay(1);
if(!nopoll_conn_wait_until_connection_ready(conn, 0)) continue;
if(nopoll_conn_complete_pending_write(conn) != 0) continue;

msg = nopoll_conn_get_msg(conn);
if(msg) {
  const char * content = (const char *) nopoll_msg_get_payload(msg);
  printf("[%d] Message Received OpCode: %d Message: %s\n", system_get_time()/1000, nopoll_msg_opcode(msg), content);
  if(nopoll_msg_opcode(msg) == 1) {
    if(nopoll_cmp(content, "ping")) { printf("Sending Ping ...\n"); nopoll_conn_send_ping(conn); continue;
    } else {
            nopoll_conn_send_text(conn, nopoll_msg_get_payload(msg), nopoll_msg_get_payload_size(msg));
    }

    if(msg) nopoll_msg_unref(msg);

  }

}

`

francisbrosnan commented 8 years ago

Hello, I've been trying to reproduce the problem and your code looks good. We have here then several possibilities but I suspect this could be solved by using latest stable noPoll source code from github.com (rev 291 is stable). If problem persists, it might be cause by an unallocated resource causing mask bit (should be only from client to server) turns at the server so it happens too from server to client. Best Regards

francisbrosnan commented 8 years ago

Closing as no response was received. Can't reproduce bug. Thanks for reporting. Best Regards