处理 Cometd 异常
Dealing with Cometd exceptions
多年来我一直在使用 Cometd Java API 的各种版本(目前是 v2.5.1)并且一切都按预期工作。但是我的日志充满了很多异常,主要是 java.io.IOException
和 org.eclipse.jetty.io.EofException
。
我遇到了 this forum post,其中解释了至少一个异常,即 "Broken pipe" 可以忽略:
This exception is caused by writing to a socket that's been closed by
the remote end. Your client decided to abruptly close the socket. If
this is a real log (as opposed to a test log), the client could have
closed the browser, put the computer in sleep, etc.
Just ignore it.
现在,我的日志中出现了更多的异常,这些异常多年来一直存在,有关更详细的堆栈跟踪,请参阅下面的实际问题:
java.io.IOException: closedOut 1006:null
java.io.IOException: closedOut 1006:null
org.eclipse.jetty.io.EofException: Closed
java.io.IOException: Connection reset by peer
因此我的问题是:忽略这些异常是否也安全,或者有什么我可以更改代码(除了更改日志级别)以确保安全?
堆栈跟踪:
12:36:28 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-20)
java.io.IOException: closedOut 1006:null
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:447) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
12:38:54 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-27)
org.eclipse.jetty.io.EofException: Closed
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.addFrame(WebSocketGeneratorRFC6455.java:80) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:449) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
12:33:46 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-45)
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.7.0_65]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.7.0_65]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.7.0_65]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.7.0_65]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487) ~[na:1.7.0_65]
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:288) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:356) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.flushBuffer(WebSocketGeneratorRFC6455.java:207) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.addFrame(WebSocketGeneratorRFC6455.java:174) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:449) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
默认情况下,CometD 服务器不会关闭连接,除非这些连接长时间处于空闲状态。
但是,由于 CometD 具有内置的心跳机制,因此连接永远不会保持空闲状态以触发服务器端关闭(假设网络稳定)。
每次遇到服务器因连接关闭而无法写入客户端的情况,一般是由于客户端关闭连接或客户端与服务器之间的网络连接故障。
在服务器端日志中可以忽略此类异常。
您在问题中报告的所有异常都是此类。
考虑升级到 CometD 3.x。
多年来我一直在使用 Cometd Java API 的各种版本(目前是 v2.5.1)并且一切都按预期工作。但是我的日志充满了很多异常,主要是 java.io.IOException
和 org.eclipse.jetty.io.EofException
。
我遇到了 this forum post,其中解释了至少一个异常,即 "Broken pipe" 可以忽略:
This exception is caused by writing to a socket that's been closed by the remote end. Your client decided to abruptly close the socket. If this is a real log (as opposed to a test log), the client could have closed the browser, put the computer in sleep, etc.
Just ignore it.
现在,我的日志中出现了更多的异常,这些异常多年来一直存在,有关更详细的堆栈跟踪,请参阅下面的实际问题:
java.io.IOException: closedOut 1006:null
java.io.IOException: closedOut 1006:null
org.eclipse.jetty.io.EofException: Closed
java.io.IOException: Connection reset by peer
因此我的问题是:忽略这些异常是否也安全,或者有什么我可以更改代码(除了更改日志级别)以确保安全?
堆栈跟踪:
12:36:28 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-20)
java.io.IOException: closedOut 1006:null
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:447) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
12:38:54 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-27)
org.eclipse.jetty.io.EofException: Closed
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.addFrame(WebSocketGeneratorRFC6455.java:80) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:449) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
12:33:46 WARN - .s.s.l.BayeuxInitializer - (pool-1-thread-45)
java.io.IOException: Connection reset by peer
at sun.nio.ch.FileDispatcherImpl.write0(Native Method) ~[na:1.7.0_65]
at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) ~[na:1.7.0_65]
at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) ~[na:1.7.0_65]
at sun.nio.ch.IOUtil.write(IOUtil.java:51) ~[na:1.7.0_65]
at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:487) ~[na:1.7.0_65]
at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:288) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:356) ~[jetty-io-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.flushBuffer(WebSocketGeneratorRFC6455.java:207) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketGeneratorRFC6455.addFrame(WebSocketGeneratorRFC6455.java:174) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.eclipse.jetty.websocket.WebSocketConnectionRFC6455$WSFrameConnection.sendMessage(WebSocketConnectionRFC6455.java:449) ~[jetty-websocket-8.1.5.v20120716.jar:8.1.5.v20120716]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:244) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport.send(WebSocketTransport.java:238) ~[cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.schedule(WebSocketTransport.java:555) [cometd-websocket-jetty-2.5.1.jar:na]
at org.cometd.websocket.server.WebSocketTransport$WebSocketScheduler.run(WebSocketTransport.java:469) [cometd-websocket-jetty-2.5.1.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_65]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_65]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_65]
默认情况下,CometD 服务器不会关闭连接,除非这些连接长时间处于空闲状态。 但是,由于 CometD 具有内置的心跳机制,因此连接永远不会保持空闲状态以触发服务器端关闭(假设网络稳定)。
每次遇到服务器因连接关闭而无法写入客户端的情况,一般是由于客户端关闭连接或客户端与服务器之间的网络连接故障。
在服务器端日志中可以忽略此类异常。 您在问题中报告的所有异常都是此类。
考虑升级到 CometD 3.x。