自从我们在Spring 4中开始使用websockets以来,我们的日志就充斥着这个例外:
3 ERROR MessageBrokerSockJS-1 handler.XhrStreamingTransportHandler$XhrStreamingSockJsSession:276 - Terminating connection after failure to send message to client. This may be because the client has gone away (see https://java.net/jira/browse/SERVLET_SPEC-44)
Feb 15 12:05:16 apmgui i-04e9bc6a: ClientAbortException: java.net.SocketException: Broken pipe
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:371)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:333)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.catalina.connector.Response.flushBuffer(Response.java:570)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.catalina.connector.ResponseFacade.flushBuffer(ResponseFacade.java:307)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.http.server.ServletServerHttpResponse.flush(ServletServerHttpResponse.java:81)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.web.socket.sockjs.transport.session.StreamingSockJsSession.writeFrameInternal(StreamingSockJsSession.java:99)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.writeFrame(AbstractSockJsSession.java:273)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession.sendHeartbeat(AbstractSockJsSession.java:294)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession$1.run(AbstractSockJsSession.java:309)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.FutureTask.run(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.lang.Thread.run(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: Caused by: java.net.SocketException: Broken pipe
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.net.SocketOutputStream.socketWrite0(Native Method)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.net.SocketOutputStream.socketWrite(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at java.net.SocketOutputStream.write(Unknown Source)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:215)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:480)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.coyote.http11.InternalOutputBuffer.flush(InternalOutputBuffer.java:119)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.coyote.http11.AbstractHttp11Processor.action(AbstractHttp11Processor.java:805)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.coyote.Response.action(Response.java:174)
Feb 15 12:05:16 apmgui i-04e9bc6a: at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:366)
Feb 15 12:05:16 apmgui i-04e9bc6a: ... 17 more
我们可以做些什么来阻止这种情况?