jetty.io.EofException Broken pipe

来源:互联网 发布:oppo手机的mac地址 编辑:程序博客网 时间:2024/05/21 06:49

jetty.io.EofException
java.io.IOException: Broken pipe

Error Log

Caused by: org.eclipse.jetty.io.EofException          at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:912)          at org.eclipse.jetty.http.AbstractGenerator.blockForOutput(AbstractGenerator.java:499)          at org.eclipse.jetty.http.AbstractGenerator.flush(AbstractGenerator.java:430)          at org.eclipse.jetty.server.HttpOutput.flush(HttpOutput.java:84)          at org.eclipse.jetty.server.HttpConnection$Output.flush(HttpConnection.java:1140)          at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:165)          at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:92)          at java.io.ByteArrayOutputStream.writeTo(ByteArrayOutputStream.java:109)          at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:258)          at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:107)          at org.eclipse.jetty.server.HttpWriter.write(HttpWriter.java:96)          at org.eclipse.jetty.io.UncheckedPrintWriter.write(UncheckedPrintWriter.java:271)          ... 35 more  Caused by: java.io.IOException: Broken pipe          at sun.nio.ch.FileDispatcher.write0(Native Method)          at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:29)          at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:72)          at sun.nio.ch.IOUtil.write(IOUtil.java:28)          at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:334)          at org.eclipse.jetty.io.nio.ChannelEndPoint.flush(ChannelEndPoint.java:187)          at org.eclipse.jetty.io.nio.SelectChannelEndPoint.flush(SelectChannelEndPoint.java:277)          at org.eclipse.jetty.http.HttpGenerator.flushBuffer(HttpGenerator.java:856)          ... 46 more  

jetty准备会写response发现connection已经被关闭

It’s not Jetty. It is broken TCP pipe due to client-side. It happens when client closes TCP connection.

Broken pipe产生的原因通常是当管道读端没有在读,而管道的写端继续有线程在写,就会造成管道中断。(由于管道是单向通信的) SIGSEGV(Segment fault)意味着指针所对应的地址是无效地址,没有物理内存对应该地址。 以下是UNIX的信号解释:

A

在WIN环境变量中设置: _JAVA_SR_SIGNUM =12, 若Linux下用 export _JAVA_SR_SIGNUM =12, 基本就可以解决.

11 / SIGSEGV: Unerlaubter Zugriff auf Hauptspeicher (Adressfehler). 12 / SIGUSER2: User-defined Signal 2 (POSIX). 

把_JAVA_SR_SIGNUM改成12只是将信号至成user-defined,让它不报出来而已,不能解决问题。

# 在连接高峰期间经常出现这样的问题,tomcat在linux下也出现类似情况。# sun的解释:  --posted by: cooper   Below is a clipping from Sun on working around JVM crashes under high   thread counts in the JVM 1.3 for Linux   On Linux, use a larger signal number for hotspot thread   suspension/resumption handler. The signal number being used is   specified by environment variable _JAVA_SR_SIGNUM. Setting it to a   number larger than SIGSEGV (11) will solve the PRoblem. A good number   to use is 12, which is SIGUSR2. Using signal 16 to work around the   problem might have potential problems. So on tcsh, "setenv   _JAVA_SR_SIGNUM 12" can solve the problem.

B

将jetty io类UncheckedPrintWriter crack掉
其中的属性_throwUnchecked=true正式控制异常是否向上抛出的开关,把它修改掉,然后将这个class单独打成jar包。

reference

http://lucene.472066.n3.nabble.com/jetty-error-broken-pipe-td3522120.html
http://trinea.iteye.com/blog/1231788
http://benni82.iteye.com/blog/840878
https://www.evernote.com/shard/s95/sh/33fe6db4-03a2-45d5-b7a3-6a6c35e5d864/a88a0f85148d56fe96e3b0df83ff7349