users@websocket-spec.java.net

[jsr356-users] [jsr356-experts] Re: Pings and Pongs

From: Mark Thomas <mark_at_homeinbox.net>
Date: Sun, 05 Aug 2012 10:05:50 +0100

Resending from the right address.

On 13/07/2012 03:10, Joe Walnes wrote:
>
>
> On Thu, Jul 12, 2012 at 6:24 PM, Danny Coward <danny.coward_at_oracle.com
> <mailto:danny.coward_at_oracle.com>> wrote:
>
> So it looks to me that for the JSR API, this means:-
>
> a) API to send pings, something like: public void sendPing(byte[]
> applicationData) on RemoteEndpoint.
> b) A ping-pong should reset the idle timeout on the connection.
> c) API to receive pongs, something like: public void onPong(byte[]
> applicationData) on MessageListener
> d) implementations should answer a ping with a pong with the same
> data as soon as possible after receiving it.

+1

> Sounds good. A few things to add:
>
> * As well as sendPing and onPong, we also need to support the opposite
> direction for when the client initiates the ping. i.e. onPing, sendPong.

+1

> * Most (but not all) applications don't care about implementing their
> own ping/pong rules. It should be easy for applications to use
> predefined ping/pong strategies (e.g. reply to pings from client, send
> heartbeat pings from server with timeout, etc), without having to
> duplicate code. Maybe this is a vendor specific feature - or maybe it
> could be implemented in user-space with a Filter equivalent for the
> WebSockets.

I'd expect the implementation to provide a default implementation that
applications could override if they wanted to.

Mark