我使用spring-boot-starter-websocket和spring boot 1.5.3.RELEASE 当sockjs试图执行心跳任务时,我得到了大量的日志 不知怎的,连接丢失了。 this article表示已关闭(根据JIRA),但我仍然遇到同样的问题
这是我的配置
@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
@Bean
WebSocketHandler getWsHandler() {
return new WebSocketHandler();
}
@Override
public void configureMessageBroker(MessageBrokerRegistry config) {
config.enableSimpleBroker("/topic");
}
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
registry.addEndpoint("/ws").setAllowedOrigins("*").withSockJS();
} }
以下是日志
2017-07-11 15:10:23.753 INFO 7574 --- [MessageBroker-4] o.apache.coyote.http11.Http11Processor:发生错误 在非容器线程上处理。连接将是 立即关闭
java.io.IOException:断开管道 sun.nio.ch.FileDispatcherImpl.write0(原生方法)〜[na:1.8.0] at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) 〜[na:1.8.0] at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)〜[na:1.8.0] at sun.nio.ch.IOUtil.write(IOUtil.java:65)〜[na:1.8.0] at at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:466) 〜[na:1.8.0] at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:134) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:157) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.NioEndpoint $ NioSocketWrapper.doWrite(NioEndpoint.java:1259) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:670) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.SocketWrapperBase.flushBlocking(SocketWrapperBase.java:607) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.tomcat.util.net.SocketWrapperBase.flush(SocketWrapperBase.java:597) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.coyote.http11.Http11OutputBuffer.flushBuffer(Http11OutputBuffer.java:581) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.coyote.http11.Http11OutputBuffer.flush(Http11OutputBuffer.java:272) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.coyote.http11.Http11Processor.flush(Http11Processor.java:1506) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.coyote.AbstractProcessor.action(AbstractProcessor.java:279) 〜[tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.coyote.Response.action(Response.java:172) [tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:317) [tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:284) [tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.catalina.connector.Response.flushBuffer(Response.java:541) [tomcat-embed-core-8.5.14.jar:8.5.14] at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:312) [tomcat-embed-core-8.5.14.jar:8.5.14] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:176) [tomcat-embed-core-8.5.14.jar:8.5.14] at javax.servlet.ServletResponseWrapper.flushBuffer(ServletResponseWrapper.java:176) [tomcat-embed-core-8.5.14.jar:8.5.14] at org.springframework.security.web.util.OnCommittedResponseWrapper.flushBuffer(OnCommittedResponseWrapper.java:159) [spring-security-web-4.2.2.RELEASE.jar:4.2.2.RELEASE] at org.springframework.http.server.ServletServerHttpResponse.flush(ServletServerHttpResponse.java:96) [spring-web-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJsSession.writeFrameInternal(AbstractHttpSockJsSession.java:350) [spring-websocket-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:322) [spring-websocket-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendHeartbeat(AbstractSockJsSession.java:255) [spring-websocket-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession $ HeartbeatTask.run(AbstractSockJsSession.java:456) [spring-websocket-4.3.8.RELEASE.jar:4.3.8.RELEASE] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) [spring-context-4.3.8.RELEASE.jar:4.3.8.RELEASE] at java.util.concurrent.Executors $ RunnableAdapter.call(Executors.java:511) [na:1.8.0] at java.util.concurrent.FutureTask.run(FutureTask.java:266)[na:1.8.0] 在 java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.access $ 201(ScheduledThreadPoolExecutor.java:180) [na:1.8.0] at java.util.concurrent.ScheduledThreadPoolExecutor中的$ ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [na:1.8.0] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0] at java.util.concurrent.ThreadPoolExecutor中的$ Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0]在java.lang.Thread.run(Thread.java:744)[na:1.8.0]}