关于servlet下载-ClientAbortException: java.io.IOException

时间:2022-10-30 08:33:24

关于servlet下载-ClientAbortException:  java.io.IOExceptionservlet下载异常:

            ClientAbortException:  java.io.IOException

 

今天在搞下载(svn下载和本地下载),发现下面几个问题:

1,弹出下载框,取消之后,再下载就会报错

2,正常下载,使用迅雷,经常下载到一点点就报错,要么直接是无法建立连接

3,图片文件直接用ie下载打开没问题

 

网上搜了好多,没人解决,自己做了很多尝试都是时好时坏。。。最后从这儿找到了一些灵感。

最后终于搞定了,问题出在Tomcat的connectionTimeout(网络连接超时时间毫秒数),就是这个东西。仔细想想确实是,

当你从ie直接打开下载链接,排除你的网络很慢慢的情况,2(connectionTimeout默认2000毫秒)秒一般是可以的(而且我是本地测试的)。

但是用迅雷下载时,从点击下载...启动迅雷...准备...建立链接...开始下载。如果网速不好,尤其本地测试用这种网络下载工具,2秒就不够了。

我将connectionTimeout改大了点,改成3秒,就没问题了,想怎么下怎么下。。。。。。

 

贴出异常代码:

ClientAbortException:  java.io.IOException
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:406)
at org.apache.tomcat.util.buf.ByteChunk.append(ByteChunk.java:371)
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:431)
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:419)
[10-09 15:25:28][]-[UI.FileManage.OnlineFileManagerServlet.localDownloadFile(OnlineFileManagerServlet.java:183)] -INFO -OutputStream flushed error:null
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:91)
at UI.FileManage.OnlineFileManagerServlet.localDownloadFile(OnlineFileManagerServlet.java:178)
at UI.FileManage.OnlineFileManagerServlet.processRequest(OnlineFileManagerServlet.java:116)
at UI.FileManage.OnlineFileManagerServlet.doGet(OnlineFileManagerServlet.java:614)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:99)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1023)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:589)
at org.apache.tomcat.util.net.AprEndpoint$SocketProcessor.run(AprEndpoint.java:1852)

at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: java.io.IOException
at org.apache.coyote.http11.InternalAprOutputBuffer.flushBuffer(InternalAprOutputBuffer.java:205)
at org.apache.coyote.http11.InternalAprOutputBuffer.access$100(InternalAprOutputBuffer.java:37)
at org.apache.coyote.http11.InternalAprOutputBuffer$SocketOutputBuffer.doWrite(InternalAprOutputBuffer.java:235)
at org.apache.coyote.http11.filters.IdentityOutputFilter.doWrite(IdentityOutputFilter.java:84)
at org.apache.coyote.http11.AbstractOutputBuffer.doWrite(AbstractOutputBuffer.java:192)
at org.apache.coyote.Response.doWrite(Response.java:517)
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:401)
... 25 more