Hi,

I am new to using Jetty websockets API. I already posted my question on
stackoverflow, but no response yet.

Reference:
http://stackoverflow.com/questions/22852773/more-than-one-jetty-websocketservlet-url-not-working

I'm using jetty 8.1.4, and this application I'm working on originally
supports one WebSocketServlet url path. The URL for the server is something
like:

URL1: ws://localhost:8081/user/1/feeda?x=1&y=2

Now I want to have another websocket path which will share a lot of the
same framework code.

URL2: ws://localhost:8081/user/1/feedb?z=1

First of all, please correct me if I'm wrong in my understanding, and I
can't have more than one websocket per server.

Current code:

public class FeedAServlet extends WebSocketServlet {
}

public class HealthServlet extends HttpServlet {
}

public class MyWebSocketServer extends Thread {
 .
 .

        ServletContextHandler context = new
ServletContextHandler(ServletContextHandler.SESSIONS);
        context.setContextPath("/user");
        getSocketServer().setHandler(context);

        context.addServlet(new ServletHolder(new FeedAServlet()), "/");
        context.addServlet(new ServletHolder(new HealthServlet()), "/status");


        startPubSub();
        getSocketServer().start();
        getSocketServer().join();
 .
 .

}

My changes to add the new WebSocketServlet FeedBServlet. Here, I want to
explicitly specify my two url paths unlike use of "/" earlier:

public class FeedBServlet extends WebSocketServlet {
}


public class MyWebSocketServer extends Thread {
 .
 .
        context.addServlet(new ServletHolder(new FeedAServlet()), "/feeda");
        context.addServlet(new ServletHolder(new FeedBServlet()), "/feedb");
        context.addServlet(new ServletHolder(new HealthServlet()), "/status");
 .
 .
}

However, now both my URL1 and URL2 are not working. Please tell me what I
might be missing.

Alternative:

Now I am wondering if there is any solution for this, or if upgrading to
jetty 9 will let me create a new websocket depending on the matching url.
Similar to your example code in MyAdvancedEchoServlet, will I be able to
conditionally direct the current request to the appropriate socket?

http://www.eclipse.org/jetty/documentation/current/jetty-websocket-server-api.html#d0e21192

Please HELP!!!

Thanks in advance.
L
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to