Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-dev] websocket timeouts

Joakim,

I've had a look at the websocket timeouts and I think it is mostly there.

Idle timeouts are implemented by the endpoint itself, so you will
inherit that mechanism when the endpoint is upgraded from HTTP to
WebSocket.

When the endpoint detects that it is idle, it calls AbstractWebSocketConnection


    @Override
    protected boolean onReadTimeout()
    {
        LOG.debug("Read Timeout. disconnecting connection");
        // TODO: notify end user websocket of read timeout?
        return true;
    }


However I think this method needs to be changed to the psuedo coding

    @Override
    protected boolean onReadTimeout()
    {
         if (iostate==CLOSING || iostate==CLOSED)
           return true;

         close(StatusCode.NORMAL,"Idle");
         return false;
    }

So on the first idle timeout, the websocket will send a close(1000)
control message, which should solicit a gentle close.  But if not and
a second idle timeout occurs, then a the connection will be hard
closed.

I think 1000 is the right status code??

The next thing to do is to make sure that Session.setIdleTimeout(ms)
is correctly wired up.   First issue I see is that the javadoc says
the timeout is in milliseconds, but the implementation in
WebSocketSession says it is in seconds.

Then I think that a call to that method needs to eventually end up on
a call to set the endpoints idle timeout.... at least in the non MUX
case.

For the mux case, you will need to implement your own timeout
mechanism.    You can still have the timeout from the EndPoint, but
that should be set to be some kind of uber timeout and never really
used unless all mux channels were closed.   The MUX then needs to have
an instance of IdleTimeout for each channel in the mux, with the call
to onIdleExpired wired up to call the WebSocketConnection
onreadTimeout()


cheers






-- 
Greg Wilkins <gregw@xxxxxxxxxxx>
http://www.webtide.com
Developer advice and support from the Jetty & CometD experts.
Intalio, the modern way to build business applications.


Back to the top