IOException:文件下载期间由对等方重置连接

时间:2017-08-08 06:26:22

标签: java

最近我们在生产中遇到了一个问题(下面提供了Stacktrace)。需要帮助来解决该问题。  我在SO中经历了许多问题和答案,发现根本原因是:

  

"此错误的常见原因是您已写入   已经被另一端关闭的连接"

但是在生产中它从最后2个月开始发生。在那之前没有问题。此外,最近没有代码更改。  需要你帮助找到这个问题的根本原因。

StackTrace:

 Caused by: org.apache.catalina.connector.ClientAbortException: java.io.IOException: Connection reset by peer
    at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:393)
    at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:426)
    at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:339)
    at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:418)
    at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:406)
    at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:97)
    ... 28 more
Caused by: java.io.IOException:     
    at sun.nio.ch.FileDispatcherImpl.write0(Native Method)
    at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47)
    at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93)
    at sun.nio.ch.IOUtil.write(IOUtil.java:65)
    at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:492)
    at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:124)
    at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101)
    at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:172)
    at org.apache.coyote.http11.InternalNioOutputBuffer.writeToSocket(InternalNioOutputBuffer.java:139)
    at org.apache.coyote.http11.InternalNioOutputBuffer.addToBB(InternalNioOutputBuffer.java:197)
    at org.apache.coyote.http11.InternalNioOutputBuffer.access$000(InternalNioOutputBuffer.java:41)
    at org.apache.coyote.http11.InternalNioOutputBuffer$SocketOutputBuffer.doWrite(InternalNioOutputBuffer.java:320)

代码:

long size = 0;
 try {
            byte[] buff = new byte[buffSize * 1024];
            int len;
            while ((len = in.read(buff)) != -1) {
                out.write(buff, 0, len);
                size += len;
            }
        } catch (Exception e) {
            // 
        } finally {
        in.close()
        out.close();
        }

out.write()行抛出异常。 请帮忙

0 个答案:

没有答案