org.apache.catalina.connector.ClientAbortException

org.apache.catalina.connector.ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:410)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:442)
    at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:359)
    at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:334)
    at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:101)
    at javax.imageio.stream.FileCacheImageOutputStream.close(FileCacheImageOutputStream.java:238)
    at javax.imageio.ImageIO.write(ImageIO.java:1580)
    at com.tts.vcode.servlet.SlideVerifyCodeServlet.generateImage(SlideVerifyCodeServlet.java:61)
    at com.tts.vcode.servlet.SlideVerifyCodeServlet.service(SlideVerifyCodeServlet.java:33)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
    at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:1025)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1136)
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
    at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:318)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:159)
    at org.apache.coyote.http11.InternalOutputBuffer.realWriteBytes(InternalOutputBuffer.java:216)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:442)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:347)
    at org.apache.coyote.http11.InternalOutputBuffer$OutputStreamOutputBuffer.doWrite(InternalOutputBuffer.java:239)
    at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:117)
    at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:192)
    at org.apache.coyote.Response.doWrite(Response.java:495)
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:405)
    ... 29 more

上述问题分析:

在网上查找了了下原因,大概归结为: 
ClientAbortException: java.net.SocketException: Connection reset by peer: socket write error的原因是由于处理http连接时,正在输出内容时,用户关闭了IE,会出现一个"ClientAbortException",属于I/O处理中出现的一个异常,应用服务器应该会捕捉。 
Connection reset by peer的原因: 
经常出现的Connection reset by peer: 原因可能是多方面的,不过更常见的原因是: 
①:服务器的并发连接数超过了其承载量,服务器会将其中一些连接Down掉; 
②:客户关掉了浏览器,而服务器还在给客户端发送数据; 
③:浏览器端按了Stop 

        很多人都说是客户端造成的,没有办法控制,而且后台会记录这个异常,日志也会疯狂爆满,时间长了,肯定会DOWN掉的.
       
        本人觉得大多数可能是第二条问题的原因引起的,即大多数浏览器阻止了窗口的弹出,相当于客户关掉了浏览器,可等效于浏览器端按了Stop ,而这时服务器端还在给客户端发送数据,所以产生了上异常,经过本人的测试,发现只需将网站地址(或本机地址)加入"受信任的站点"即可解决问题,因为这样设置了以后,浏览器就不会阻止窗口的弹出了,这样浏览器就会等到服务器端发送完数据后再进行下面的动作.因而异常就不会发生了.

看看在输出流在还没有结束的时候是不是又发送了新的请求。

上述问题解决办法:  "工具->internet(选项..)->安全->受信任的站点->站点",将地址加入即可避免这个异常。

你可能感兴趣的:(java)