本文所使用的技术为spring mvc + tomcat7实现的tomcat技术,在刷新页面后出现异常
错误关键字
java.util.concurrent.ExecutionException: java.net.SocketException:
Software caused connection abort: socket write error]
异常方法为:public void handleTransportError(WebSocketSession webSocketSession, Throwable e)
throws Exception {}
如下图:
22:26:46.360 [http-bio-8080-exec-2] ERROR com.webchat.websocket.ChatWebSocketHandler - []
java.net.SocketException: Software caused connection abort: socket write error]
22:26:46.361 [http-bio-8080-exec-2] ERROR com.webchat.websocket.ChatWebSocketHandler -
[] [websocket 连接异常2,:->Message will not be sent because the WebSocket session has been closed]
window.onbeforeunload = function(event) {
ws.onclose =function(){};
ws.close();
}
该问题主要发生在页面刷新的时候,ws连接实际已经断开,但前后台均为做断开操作,后台一直保持连接,待前端断开后,却没有释放掉该连接,故后台还在有状态的监听使用故报错。
另连接时间过长浏览器自动切断时也会出现此问题