sprsquish/finagle-libs — pull request #3 by Sebruck (2014-07-29 15:36:57+00:00)
Title: Ignore PongWebSocketFrame in WebSocketServerHandler

We started using this library live and experienced this exceptions several hundred times a minute:

```
[gflive] twitter: java.lang.IllegalArgumentException: invalid message "PongWebSocketFrame(data: EmptyChannelBuffer(ridx=0, widx=0, cap=0))"
[gflive] twitter: at com.twitter.finagle.websocket.WebSocketServerHandler.messageReceived(WebSocketHandler.scala:110) [gflive] twitter: at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:296)
[gflive] twitter: at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462)
[gflive] twitter: at org.jboss.netty.handler.codec.replay.ReplayingDecoder.callDecode(ReplayingDecoder.java:536)
[gflive] twitter: at org.jboss.netty.handler.codec.replay.ReplayingDecoder.messageReceived(ReplayingDecoder.java:435)
[gflive] twitter: at com.twitter.finagle.channel.ChannelStatsHandler.messageReceived(ChannelStatsHandler.scala:81)
[gflive] twitter: at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
[gflive] twitter: at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
[gflive] twitter: at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88)
[gflive] twitter: at org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108)
[gflive] twitter: at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:318)
[gflive] twitter: at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89)
[gflive] twitter: at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178)
[gflive] twitter: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
[gflive] twitter: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
[gflive] twitter: at java.lang.Thread.run(Thread.java:722
```

which resulted in the following warning (and shutting down of connections):
(invoked by https://github.com/twitter/finagle/blob/dd21663a44e12cd2db9e5c2afd8008ed77d34f23/finagle-core/src/main/scala/com/twitter/finagle/netty3/Netty3Listener.scala)

```
[gflive] twitter: Unhandled exception in connection with /XXX.XXX.XXX.XXX:XXXXX , shutting down connection
```

This happens because somehow some clients are sending a PongWebSocketFrame to the server without receiving a PingWebSocketFrame first (as far as i saw it, the library never sends a Ping?).

When the server receives a PongWebSocketFrame, we don't want to throw an exception but just ignore it.

This change solved our problem.