Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jetty-users] Closing a jaxa.websocket.WebSocketContainer in Jetty 9.1

just following up on an old thread.

Would it be possible to at least mark all jetty threads as daemon threads?


A simple test like this is stuck forever. Because all the jetty threads are non daemon threads

@ClientEndpoint

public class Test {

    public static void main(String[] args) throws Exception {

        WebSocketContainer ws = ContainerProvider.getWebSocketContainer();

        ws.connectToServer(new Test(), new URI("ws://wuhu.wuhu"));

    }

}


Cheers
  Kasper






On Mon, Sep 9, 2013 at 6:25 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
The JSR-356 websocket containers do not have a lifecycle.
It is expected that you request only 1 WebSocketContainer and use it for the life of your JVM.

Avoid using ContainerProvider.getWebSocketContainer() multiple times.

Note, if all you are wanting is a container suitable for instantiating outgoing connections from a web application, then you can access the ServerContainer from
ServerContainer container = (ServerContainer) HttpServletRequest.getAttribute("javax.websocket.server.ServerContainer");

There is only ever 1 of those (per web application)
From there you can use the container.connectToServer() calls like before.


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


On Mon, Sep 9, 2013 at 7:18 AM, Kasper Nielsen <kasperni@xxxxxxxxx> wrote:
Hi,

I'm trying to port an existing Jetty 9.0 websocket implementation to javax.websocket.

I'm creating a WebSocketContainer using 
  WebSocketContainer container = ContainerProvider.getWebSocketContainer();
which will pick up an instance of ClientContainer/ServerContainer.

What is the preferred way to shut down the container again seeing that WebSocketContainer does not have lifecycle methods?

((org.eclipse.jetty.util.component.ContainerLifeCycle) container).stop();
works but depends on the Jetty implementation.

Cheers
  Kasper

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



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



Back to the top