【问题标题】:Tomcat 8 - websockets session and replicationTomcat 8 - websockets 会话和复制
【发布时间】:2013-12-09 05:35:12
【问题描述】:

我用 tomcat 8 websockets 创建了一个简单的项目。这是一个sn-p:

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");

如您所见,websocket 使用对象 Session (javax.websocket.session) 我的问题是,当我进入 tomcat 的管理器应用程序时,我在监视器上看不到任何会话。 我相信因为它寻找的是 httpSession 而不是 websocket 会话。

所以 2 个问题:

1) 有没有办法在 tomcat 实例上监控这些 websocket 会话?

2) websocket 会话是否也有类似会话复制 (httpSession) 的方法?

谢谢!

【问题讨论】:

    标签: session tomcat websocket


    【解决方案1】:

    有趣,似乎有一种方法可以根据 WebSocket 活动更新 HttpSession。 看到这个Discussion about WebSocket SPEC 175

    您可以尝试使用Spring-Session。它可以在其 HttpSession 集成之上同时解决会话复制和 WebSocket 会话。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-12
      • 2018-01-01
      • 1970-01-01
      • 2023-03-04
      相关资源
      最近更新 更多