zoukankan      html  css  js  c++  java
  • java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method 解决办法

    java.lang.IllegalStateException: The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.checkState(WsRemoteEndpointImplBase.java:1015)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase$StateMachine.textStart(WsRemoteEndpointImplBase.java:978)
    at org.apache.tomcat.websocket.WsRemoteEndpointImplBase.sendString(WsRemoteEndpointImplBase.java:161)
    at org.apache.tomcat.websocket.WsRemoteEndpointBasic.sendText(WsRemoteEndpointBasic.java:37)

    Bad:

    @OnMessage
    public String onMessage(String message, Session session) {
       ...
       return message;
    }
    

    Good:

    @OnMessage
    public void onMessage(String message, Session session) {
       ...
    }
    再次测试
    public  void  handleTextMessage(WebSocketSession session,TextMessage message){
        ...
    }
    改为
    public synchronized void  handleTextMessage(WebSocketSession session,TextMessage message){
        ...
    }
    或者
    String websocketsesssion_id = map_id.get(username);
    WebSocketSession wss = map_users.get(websocketsesssion_id);
    synchronized(wss) {
     wss.sendMessage(new TextMessage(new java.util.Date()));
    }

  • 相关阅读:
    PHP中的闭包详解
    PHPDoc 学习记录
    php中注释有关内容
    命名空间 转
    php命名空间学习笔记。
    php命名空间详解
    命名空间
    php作用域限定符
    nginx负载均衡
    naginx安装入门
  • 原文地址:https://www.cnblogs.com/interdrp/p/4866129.html
Copyright © 2011-2022 走看看