我正在使用spring web socket api在我的应用程序中实现Web Socket连接。我已经通过使用以下链接中的示例扩展Spring TextWebSocketHandler来实现这一点。
http://www.devglan.com/spring-boot/spring-websocket-integration-example-without-stomp
大部分时间都有效。但是,连接有时停止,我看到下面的错误,其中存在连接失败。
DEBUG [http-nio-8222-exec-9] [138F0E344FB38D5997135FD3BEF59EC2] 2017-12-06 05:33:44,418 LoggingWebSocketHandlerDecorator.java | (62) - StandardWebSocketSession中的传输错误[id = 20,uri = / connect / app-socket] java.io.EOFException的 在org.apache.tomcat.util.net.NioEndpoint $ NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1134) 在org.apache.tomcat.util.net.NioEndpoint $ NioSocketWrapper.read(NioEndpoint.java:1074) 在org.apache.tomcat.websocket.server.WsFrameServer.onDataAvailable(WsFrameServer.java:63) at org.apache.tomcat.websocket.server.WsHttpUpgradeHandler.upgradeDispatch(WsHttpUpgradeHandler.java:148) 在org.apache.coyote.http11.upgrade.UpgradeProcessorInternal.dispatch(UpgradeProcessorInternal.java:54) 在org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:53) at org.apache.coyote.AbstractProtocol $ ConnectionHandler.process(AbstractProtocol.java:767) 在org.apache.tomcat.util.net.NioEndpoint $ SocketProcessor.doRun(NioEndpoint.java:1347) 在org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread $ WrappingRunnable.run(TaskThread.java:61) 在java.lang.Thread.run(Thread.java:748) DEBUG [http-nio-8222-exec-9] [138F0E344FB38D5997135FD3BEF59EC2] 2017-12-06 05:33:44,418 LoggingWebSocketHandlerDecorator.java | (70) - 用CloseStatus关闭StandardWebSocketSession [id = 20,uri = / connect / app-socket] [code = 1006,reason = null]