PingWebSocketFrame

616 views
Skip to first unread message

Will Sargent

unread,
Aug 21, 2012, 4:52:20 AM8/21/12
to play-fr...@googlegroups.com
Hi all,

I noticed that the Websocket API defines a "ping" and "pong" keepalive
system, and Netty has a PingWebSocketFrame. It doesn't seem to be
referenced in the Play 2.1 trunk, and I'm wondering if I should just
implement a scheduled "ping" message myself to keep the connection
open, or if there's another way to tell when the websocket connection
has closed.

Will.

Alex Jarvis

unread,
Dec 31, 2012, 1:54:28 PM12/31/12
to play-fr...@googlegroups.com
Did you find a solution to this? I would like to send ping control frames as defined in the websocket protocol spec.

Also, to be compliant Play should respond to Ping requests.

Has anyone run it against the Autobahn WebSocket test suite? http://autobahn.ws/testsuite

Will Sargent

unread,
Dec 31, 2012, 9:32:31 PM12/31/12
to play-fr...@googlegroups.com
The way I fixed this locally was to use SSE instead of WebSocket.

If you look at Lila (https://github.com/ornicar/lila), he implements
Ping and Pong on top of the Play 2.1 framework, using *Hub and *Socket
classes, so that might be a way to go.

Will.
> --
>
>

Alex Jarvis

unread,
Jan 1, 2013, 9:24:19 AM1/1/13
to play-fr...@googlegroups.com
Thanks for the link!

It appears that he just implements his own version of Ping/Pong with Json instead of the control frames as in the WebSocket spec. I think this is quite a good approach however because I don't think that the Ping/Pong control frames are exposed in the HTML5 API yet (http://dev.w3.org/html5/websockets/#ping-and-pong-frames), so it would only work with other (non-browser) clients.

--



Nilanjan Raychaudhuri

unread,
Feb 24, 2014, 12:33:32 PM2/24/14
to play-fr...@googlegroups.com
This is fixed in master

https://github.com/playframework/playframework/pull/2130

Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri

Alex Jarvis

unread,
Feb 26, 2014, 5:22:32 AM2/26/14
to play-fr...@googlegroups.com
Thanks for the update Nilanjan. Do you know how to perhaps notify the application that the ping frame was received?

I am currently using a Json ping message to keep a 'list' of active users and their subscriptions. If a client does not send a ping within a specified timeout their socket is closed.

I would be interested to hear your thoughts on this.

Thanks,
Alex
Reply all
Reply to author
Forward
0 new messages