1
votes

I've created a simple project with tomcat 8 websockets. here is a snippet:

public void onMessage(String message, Session session) 
    throws IOException, InterruptedException {

    // Print the client message for testing purposes
    System.out.println("Received: " + message);

    // Send the first message to the client
    session.getBasicRemote().sendText("This is the first server message");

As you can see , the websocket make use with the object Session (javax.websocket.session) My problem is, when i enter the tomcat's manager app i cant see any session on the monitor. I believe because it looks for httpSession and not websocket sesssion.

So 2 questions:

1) Is there a way to monitor these websocket sessions on the tomcat instance?

2) Is there a way like sesssion replication (httpSession) for websocket session as well?

thanks!

1

1 Answers

0
votes

Interesting, It seems like there is a way to update the HttpSession according to WebSocket activity. See this Discussion about WebSocket SPEC 175

You can try using Spring-Session. it can address both session replication and WebSocket session on top of its HttpSession integration.