0

My goal is to implement the RFC6455. I use Java for the back end and JavaScript WebSocket API for the front end.

What I have done:

  1. Knowning that there is no JavaScript API to send Ping/Pong frame from this SO question. So, I decided to create one from the front end.
  2. Tried to sent a Ping frame from the server.
// 137 = 1 0 0 0 1 0 1 0 // opcode = 0x09
// 0   = 0 0 0 0 0 0 0 0  // Payload len = 0
socket.getOutputStream.write(new byte[(byte) 137, 0]);

My expected result: The browser's DevTools > Network > localhost > Messages should have Ping frame that was sent by the server.

My actual result: The browser's DevTools does not receive the Ping frame nor the WebSocket.onmessage. So, I am not sure how to handle the Ping from and then send the Pong frame with WebSocket.send

kidfrom
  • 949
  • 2
  • 8
  • 17

0 Answers0