• 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()));
    }

  • 相关阅读:
    模板-树链剖分
    bzoj2523 聪明的学生
    P1220 关路灯
    BZOJ3572 [Hnoi2014]世界树
    BZOJ4013 [HNOI2015]实验比较
    BZOJ4012 [HNOI2015]开店
    BZOJ4011 [HNOI2015]落忆枫音
    BZOJ4009 [HNOI2015]接水果
    BZOJ4010 [HNOI2015]菜肴制作
    BZOJ4008 [HNOI2015]亚瑟王
  • 原文地址:https://www.cnblogs.com/interdrp/p/4866129.html
Copyright © 2020-2023  润新知