websocket-浏览器关闭报错org.apache.tomcat.websocket.WsSession@34119a89 java.io.EOFException

一、问题描述:

使用websocket的时候,前端浏览器(也可以说客户端)关闭,服务器(后端)会报错,这种情况怎么办呢?到底为什么会报错呢?

事故现场:

chatToServer-v1 · xin麒/LoverGpt - 码云 - 开源中国 (gitee.com)

https://gitee.com/flowers-bloom-is-the-sea/lover-gpt/tree/master/chatToServer-v1

2023-12-20 10:42:28.940  INFO 13108 --- [nio-8081-exec-9] com.xinqi.xinqidev.ws.ChatEndpoint       : 【websocket消息】出现未知错误 
关闭了。。。。org.apache.tomcat.websocket.WsSession@34119a89
java.io.EOFException
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1231)
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1141)
	at org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:72)
	at org.apache.tomcat.websocket.server.WsFrameServer.doOnDataAvailable(WsFrameServer.java:171)
	at org.apache.tomcat.websocket.server.WsFrameServer.notifyDataAvailable(WsFrameServer.java:151)
	at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148)
	at org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54)
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:59)
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868)
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590)
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
	at java.lang.Thread.run(Thread.java:748)

解决方案:

解决方案-websocket客户端关闭报错问题

https://mp.weixin.qq.com/s/M87UaNnzBo3lktCBufcddA

end:
最后欢迎来围观我的公众号【善于思考的编程麒】

你可能感兴趣的:(java,websocket)