Skip to content

[Question] Does the WebSocket implementation respond to empty pings? #52

Description

@jamdavi

My first inkling is it doesn't. Looking at this snippet below it seems as if if the ping request doesn't have any application data we don't send a proper pong.

It's possible this is part of the Ping/Pong spec and I'm not aware of it.

What I would assume here is if the buffer is empty we just place the FIN | PONG flags on the buffer and send it.

public void createPong(ByteBuffer ping, ByteBuffer pong) {
if ((ping == null) || (pong == null)) {
throw new IllegalArgumentException("input parameter cannot be null");
}
if (ping.capacity() > pong.capacity()) {
throw new IllegalArgumentException("insufficient output buffer size");
}
if (ping.remaining() > 0) {
byte[] buffer = ping.array();
buffer[0] = WebSocketHeader.FINBIT_MASK | WebSocketHeader.OPCODE_PONG;
pong.clear();
pong.put(buffer);
} else {
pong.clear();
pong.limit(0);
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions