New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logs fill with unnecessary stack traces when using SockJS streaming transports [SPR-11438] #16064
Comments
Rossen Stoyanchev commented The exception means that the server failed to write a message to the client. So it is a serious condition to be logged at error level. However as the message states, it may also mean simply the client went away. Unfortunately the Servlet async support -- required for SockJS' HTTP transports (in this case HTTP streaming) -- does not provide a callback when a client goes away. Hence the reference to the Servlet spec issue. Do vote there so it gets fixed, even discussing it may lead to immediate fixes in Tomcat and Jetty. This is something mentioned in the docs already by the way. See section 20.3.3. However, we can provide more guidance there and explicitly mention the impact on the logs. We may also be able to make an improvement. We could try to recognize the condition of a client having gone away from the root cause exception type and message and log it at WARNING level. That should allow filtering out such messages while still having the option to see them all if necessary. |
Rossen Stoyanchev commented This should now be resolved. For details see the commit message 42382996612825c96c745a593716f31446075a5c. |
Sachin Parikh commented I still see this error in my logs. I am running Spring version 4.0.6. I see the exception being thrown at line: 354 (throw new SockJsTransportFailureException("Failed to write " + frame, this.getId(), ex);) 04-Sep-2014 10:16:35.087 SEVERE [http-nio-8443-exec-2] org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.tryCloseWithError Closing due to exception for SockJsSession[id=td_hta6t, state=CLOSED, sinceCreated=20015, sinceLastActive=0] |
Rossen Stoyanchev commented Are you able to debug it? If you look at AbstractSockJsSession in the logWriteFrameFailure it should be obvious what we are trying to do there. There is also an explanation in the javadoc. Perhaps you can help narrow down why this stack trace is getting logged in full? |
Sachin Parikh commented Thanks for a quick response. Yes I am able to debug it and I see the control going to logWriteFrameFailure method. But even before it processes the method, I already have the broken pipe error log entry in the logs. Also, after the control goes through the writeFrame() method, I see the following error in the log: 04-Sep-2014 12:51:08.601 SEVERE [http-nio-8443-exec-2] org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator.handleTransportError Transport error for SockJsSession[id=55_fssmm, state=OPEN, sinceCreated=275108, sinceLastActive=275108] 04-Sep-2014 12:52:18.527 SEVERE [http-nio-8443-exec-1] org.springframework.web.socket.handler.ExceptionWebSocketHandlerDecorator.tryCloseWithError Closing due to exception for SockJsSession[id=tdkvxjhq, state=CLOSED, sinceCreated=335180, sinceLastActive=69923] Please note that we are using Logback for our logging Not sure if this has anything to do with the log messages. Thanks! |
Rossen Stoyanchev commented Sachin Parikh #16769 is now fixed. If you could please give 4.1.1.BUILD-SNAPSHOT a try. |
Florian GOURMELEN commented Hi I'm also having the same kind of issue Im using spring-boot-starter-websocket with spring boot 1.5.3.RELEASE And I get tons of logs when sockjs is trying to perform a heartbeat Task 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();
}
} And my log 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] } |
Prashant Deva opened SPR-11438 and commented
We are using websockets on tomcat 7.0.50 with an in memory simple spring broker.
Our logs are littered with this exception
Either:
Either way, this behavior is not documented and presence of this issue makes logs very, very heavy. Not to mention we don't know if this is an actual error in our app or one we can ignore.
Either fix this issue or provide an explanation/documentation for it.
Affects: 4.0.1
Reference URL: http://stackoverflow.com/questions/21802969/spring-4-websockets-causing-tons-of-exceptions
Issue Links:
0 votes, 7 watchers
The text was updated successfully, but these errors were encountered: