websocket java.io.EOFException: null
websocket一直在提示没有为它配置错误处理信息
2022-07-28 16:20:22.426 [http-nio-8080-exec-5] ERROR org.apache.tomcat.websocket.pojo.PojoEndpointBase:175 - No error handling configured for [org.jeecg.modules.message.websocket.WebSocket] and the following error occurred
java.io.EOFException: null
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在断开连接时就会提示这个错误,但websocket连接的时候没问题,不太清楚怎么回事,如有大佬清楚,希望可以指教一下,谢谢
解决方案:
既然提示没有为它配置错误处理,那我们就为它配置一下错误处理文章来源:https://www.toymoban.com/news/detail-503902.html
/**
* 配置错误信息处理
* @param session
* @param t
*/
@OnError
public void onError(Session session, Throwable t) {
//什么都不想打印都去掉就好了
log.info("【websocket消息】出现未知错误 ");
//打印错误信息,如果你不想打印错误信息,去掉就好了
//这里打印的也是 java.io.EOFException: null
t.printStackTrace();
}
注意上面两个参数是一点要的,不要的话启动会报错,不要问我为什么,我之前因为没给参数在百度待了两个小时才出来(主要因为自己太菜了(手动狗头))文章来源地址https://www.toymoban.com/news/detail-503902.html
到了这里,关于websocket报错:java.io.EOFException: null的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!