Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jamdavi opened this issue Sep 16, 2021 · 1 comment
Open
Labels
bug Something isn't working

Comments

@jamdavi
Copy link
Member

jamdavi commented Sep 16, 2021

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);
}
}

@conniey
Copy link
Member

conniey commented Oct 11, 2021

I'm not entirely sure. I inherited this repository... I do see some code to handle a state for WS_CONNECTED_PONG.
https://github.com/Azure/qpid-proton-j-extensions/blob/master/src/main/java/com/microsoft/azure/proton/transport/ws/impl/WebSocketImpl.java#L300

@conniey conniey added the bug Something isn't working label Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants