jsr356-experts@websocket-spec.java.net

[jsr356-experts] isActive() method removal from API

From: Bill Wigger <wigger_at_us.ibm.com>
Date: Mon, 26 Nov 2012 16:00:48 -0500

Sorry, I have another method I would like to get rid of, or be enlightened
about!

On the Session object is this method:

boolean isActive()

    Return true if and only if the underlying socket is open.
    Returns:
        whether the session is active.

What concerns me about this call is the idea that one can easily tell if
the socket is open. Using the standard socket API available from the JDK
one cannot (at least I don't know how) in a straight forward manner. This
is because if the other side closed the connection, then there is no
notification given by the JDK to any type of "socket close callback" or
"listener". How one finds out that a socket has been closed by the other
side is to do a Read or Write on the socket and get an error or "EOF" back.

But if a Read or Write fails, then the WebSocket user has already been
notified. In the case of the read/onMessage listener I'm assuming it is
via the EndPoint onError or OnClose method. In the case of a write/send an
IOException would be thrown.

So if the user is listening for messages, or sending messages, then they
will know right away if the socket is no longer open. If the user is not
listening for messages nor sending messages, I don't know how the server
will be able to "poll" the connection to see if it is active.

regards,
Bill