Bug 54381 - Websocket StreamInbound never reports receipt of a Pong
Websocket StreamInbound never reports receipt of a Pong
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
7.0.34
All All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2013-01-07 19:44 UTC by David Berkman
Modified: 2013-01-08 21:11 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description David Berkman 2013-01-07 19:44:37 UTC
The tomcat websocket api now allows the send of a Ping frame by the server (as of 7.0.33), via WsOutbound, but never reports the receipt of a Pong. See StreamInbound in the onData() method...

                } else if (opCode == Constants.OPCODE_PONG) {
                    // NO-OP
                }

As the intended use of Pings is for heartbeat messages, allowing a Ping without informing the server extension of the returned Pong leaves out half the utility.

I would suggest these changes to StreamInbound as a fix...

1) In the onData() method...

                } else if (opCode == Constants.OPCODE_PONG) {
                    onPong(frame.getPayLoad());
                }

2) Add a method onPong (ByteBuffer buffer)...

    protected void onPong(ByteBuffer buffer) {
        // NO-OP
    }

...which implementations may now override to handle Pong receipt and heartbeat logic. This is necessary as onData() is marked final, so there's no alternate workaround.
Comment 1 Mark Thomas 2013-01-08 21:11:13 UTC
Thanks for the report. Fixed in trunk and 7.0.x and will be included in 7.0.35 onwards.

The patch was a little more complex to take account of the class loader issues fixed since 7.0.33.