Spring websocket heartbeat Broken pipe IOException
Asked Answered
C

0

8

I'm using spring-boot-starter-websocket with Spring Boot 1.5.3.RELEASE. I get tons of logs when sockjs is trying to perform a heartbeat task. Somehow the connection is lost in the way. This article says its closed (according to JIRA), but I'm still having the same kind of issue.

Here is my config

@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();
    } 
}

Here are the logs

2017-07-11 15:10:23.753 INFO 7574 --- [MessageBroker-4] o.apache.coyote.http11.Http11Processor : An error occurred in processing while on a non-container thread. The connection will be closed immediately

java.io.IOException: Broken pipe at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[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 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] at 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] at java.lang.Thread.run(Thread.java:744) [na:1.8.0] }

Cowie answered 11/7, 2017 at 4:30 Comment(3)
did you solve the problem? I have exactly the same problem and can't understand how to fix itUnorthodox
I'm facing the same problem and still can't fixMayday
For the next one here facing the same problem, please describe what the client-side looks like (browser debugger). Is the websocket connection forcefully closed by the browser?Eloiseelon

© 2022 - 2024 — McMap. All rights reserved.