常见BUG Software caused connection abort: socket write error

最近碰到一个莫名的BUG:

 

ClientAbortException:  java.net.SocketException: Software caused connection abort: socket write error

at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:373)

at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:437)

at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:351)

at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:396)

at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:385)

at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:93)

at java.io.ObjectOutputStream$BlockDataOutputStream.drain(ObjectOutputStream.java:1847)

at java.io.ObjectOutputStream$BlockDataOutputStream.writeByte(ObjectOutputStream.java:1885)

at java.io.ObjectOutputStream.writeFatalException(ObjectOutputStream.java:1546)

at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:333)

at com.cc.das.ufk.StaticInfoServlet.getReservoirStaticInfo(StaticInfoServlet.java:293)

at com.cc.das.ufk.StaticInfoServlet.processRequest(StaticInfoServlet.java:72)

at com.cc.das.ufk.StaticInfoServlet.doGet(StaticInfoServlet.java:889)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)

at com.cc.das.admin.DatabaseConFilter.doFilter(DatabaseConFilter.java:146)

 

程序运行正常,数据也没有出错,后台却老是报这个错误。在网上找了别人写的博客,这个问题的原因有几个: 

①:服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉; 
②:客户关掉了浏览器,而服务器还在给客户端发送数据; 
③:浏览器端按了Stop 

④:用servlet的outputstream输出流下载图片时,当用户点击取消也会报这个错

 

花了些功夫最后找出来的原因是:用servlet的response.getOutputStream时,写回多个数据,而客户端没全部接收,可能会报下面这个错误。如: 

服务器上写了两条数据

out.writeObject("1");

out.writeObject("2");

 

客户端只接收一条

in.readObject(url);

 

这样的话也会报ClientAbortException这个错,以后注意。

 

 

你可能感兴趣的:(java,servlet,bug)