1

I try to implement client/server ping/pong.

How I know websockets have ping/pong frames.

But in vertx I don't see api for these frames, only text/binary:

WebSocket::writeFrame(WebSocketFrame.binaryFrame(...)

Should I implement ping with binary/text frame?

zella
  • 4,645
  • 6
  • 35
  • 60

1 Answers1

0

If for some reason you still would like to send a PONG frame, you can do it like that:

WebSocketFrame f = new WebSocketFrameImpl(FrameType.PONG, someBinaryDataHere);
ws.writeFrame(f);

Where ws is your WebSocket handler.

As of client, if you mean a JavaScript client, it doesn't support custom PING frames: Sending websocket ping/pong frame from browser

Alexey Soshin
  • 16,718
  • 2
  • 31
  • 40