Skip to content

Websocket: no pong response to ping packet #10

@kamplom

Description

@kamplom

What

grblHAL not respondig with pong opcodes to ping messages. Nothing arrives to the client side. No error message was triggered.

Client

Tested with python websocket-client library. It sends a packet with the ping OpCode and no data

Hack

I cannot understand the code easily so I just hardcoded a tcp_write with the OpCode for pong. websocket-client does not care about the payload in the pong response, but it should be the same as the one sent with the ping packed which triggered it.

case WsOpcode_Ping:
  if((frame_done = plen >= session->header.payload_rem)) {
      if(session->state != WsState_Closing) {
          plen -= session->header.payload_rem;
          if(collect_msg_frame(&session->header, payload, session->header.payload_rem))
              payload = session->header.frame;
          fs.opcode = WsOpcode_Pong;
          payload[0] = fs.token;

          uint8_t txbuf[5];
          if(tcp_sndbuf(session->pcb) > 4) {
              txbuf[0] = wshdr_pong.token;
              txbuf[1] = 2;
              strcpy((char *)&txbuf[2], "Hi");
              tcp_write(session->pcb, txbuf, 4, TCP_WRITE_FLAG_COPY);
              tcp_output(session->pcb);
          }
          // tcp_write(session->pcb, payload, session->header.payload_len, 1);
          // tcp_output(session->pcb);
      }
  } else {
      collect_msg_frame(&session->header, payload, plen);
      plen = 0;
  }
  break;

A proper solution should be implemented.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions