Java WebSockets: The remote endpoint was in state [TEXT_FULL_WRITING]

java Websocket 多线程向同一个session写数据,容器为tomcat

目前发现的问题是tomcat的一个bug,解决方案是:

public void sendMessage(String message) throws IOException {
        synchronized(this.session) {

            this.session.getBasicRemote().sendText(message);
        }
        //this.session.getAsyncRemote().sendText(message);
    }

使用synchronized和getBasicRemote,使用getAsyncRemote的话也会报错

https://stackoverflow.com/questions/22257079/java-websockets-the-remote-endpoint-was-in-state-text-full-writing

https://bz.apache.org/bugzilla/show_bug.cgi?id=56026

https://www.cnblogs.com/interdrp/p/4866129.html

http://blog.csdn.net/luoruixiaohai/article/details/50960319

https://stackoverflow.com/questions/33381420/tomcat-throws-the-remote-endpoint-was-in-state-binary-full-writing-when

猜你喜欢

转载自my.oschina.net/ryanzl/blog/1622135