top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Tomcat Websocket failover

+2 votes
325 views

In our current generation web application we used session replication with tomcat clustering. (and a load balancer). That way, we received an auto fail-over when a client sends an ajax request to a tomcat node that failed.

In our next generation web application, We would like to have a similar behavior, only with web-sockets. So my questions are :

1) Is it possible ?
2) Does it involve websocket-session replication? if so, are there any guides on how to do that?

posted Nov 25, 2013 by Satish Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

1) Is it possible ?

Maybe. It depends exactly what you want to do.

2) Does it involve websocket-session replication? if so, are there any guides on how to do that?

Like HTTP, WebSocket is a stateless protocol.

Unlike HTTP, WebSocket has no (that I am aware of) standard mechanism for session management. This makes fail-over tricky.

You can (with JSR356) link the HTTP session to the WebSocket session. The main issue is that unless there are HTTP requests to the session, the session will expire so you either need a long timeout or you need to be sure other requests will maintain the session.

If you store data in the HTTP session rather than the WebSocket session, Tomcat's standard session clustering mechanisms will provide session replication.

Another issue is the load-balancer. I'm not sure of the state of WebSocket support in the usual suspects for load-balancing. I took a quick look at httpd's WebSocket proxy support but it appeared to be based on the invalid assumption that all WebSocket endpoints would be under a single URL e.g. http://host:port/context/websockets/... and non-WebSocket requests.

answer Nov 26, 2013 by Kumar Mitrasen
Similar Questions
+2 votes

Is there a standard way to access ServletContext from a WebSocket ServerEndpoint ?

+3 votes

As we start load testing our jsr-356 applications, I'd like to find out if there are any websocket-specific connector settings we should be aware of for tuning the underlying websocket connection processing. Since this is a tcp socket at the end of the day, I'm assuming all the socket.* options still apply if needed.

+1 vote

I'm trying to figure out how to get access to the cookies and headers passed up in the Websocket handshake request on Tomcat 8.

In Tomcat 7 the whole HttpServletRequest was passed into the WebSocketServlet. createWebSocketInbound method so it was easy to grab from the request headers. In Tomcat 8 the querystring and URI are both exposed by the javax.websocket.Session passed to ServerEndPoint.onOpen, but I don't see a mechanism for getting the cookies or headers.

We are integrating Websocket connections into an existing web app and want to use the cookies set by our web app in the Websocket connection process.

+1 vote

I'm trying to use the Tomcat8 jsr client functionality in a standalone java client. I'm trying to use the minimal number of jars, so I gabbed websocket-api.jar ONLY. When I call ContainerProvider.getWebSocketContainer(), it returns null. Do I need another jar to resolve this on the client?

+1 vote

Has anyone had a large WS message sent as the response to an outbound call? We have a scenario where the request causes a 300K WS message to be sent back as the "response". The client is sending multiple WS continuation frames and after a couple of frames are successfully sent, Tomcat just closes the websocket connection. I the response fits in a single frame, it's fine. Where can I look to try and troubleshoot this?

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...