Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] WebSocketContainer connection timeout

The JSR-356 WebSocketContainer has no concept of a connect timeout. Sorry. (its missing from the API and Spec)

There is nothing currently in the Jetty impl of javax.websocket.WebSocketContainer to provide this in a JSR standard way.

However, if you don't mind jetty specifics ...

        import org.eclipse.jetty.websocket.jsr356.ClientContainer;
        
        WebSocketContainer container = ContainerProvider.getWebSocketContainer();
        
        // Jetty specific
        if(container instanceof ClientContainer)
        {
            ClientContainer jettyContainer = (ClientContainer) container;
            jettyContainer.getClient().setConnectTimeout(2000);
        }


--
Joakim Erdfelt <joakim@xxxxxxxxxxx>
Expert advice, services and support from from the Jetty & CometD experts


On Thu, Dec 5, 2013 at 7:33 AM, Kasper Nielsen <kasperni@xxxxxxxxx> wrote:
Hi,

I've switched from Jetty's websocket interfaces to using javax.websocket.WebSocketContainer and friends.
When I used Jetty's interfaces I could specify a connect timeout however WebSocketContainer
blocks until a connection has been made.

Anyway to control the timeout? I could spin of a thread that would interrupt the current thread. If no progress has been made in 10 seconds. But I would rather use something less hackish.

- Kasper

_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users



Back to the top