前言:
最近刚接手一个项目,发现流程中的附件下载时出现网络错误等字样,查看日志是大概是如下报错:java.io.IOException: 断开的管道
这里记录下解决方式。
2021-11-10 12:55:11.275 |-ERROR [http-nio-24987-exec-5] com.hundsun.fais.fhg.controller.FileController [] -| 文件下载失败
org.apache.catalina.connector.ClientAbortException: java.io.IOException: 断开的管道
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:372) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:841) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at org.apache.catalina.connector.OutputBuffer.append(OutputBuffer.java:746) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at org.apache.catalina.connector.OutputBuffer.writeBytes(OutputBuffer.java:407) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at org.apache.catalina.connector.OutputBuffer.write(OutputBuffer.java:385) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at org.apache.catalina.connector.CoyoteOutputStream.write(CoyoteOutputStream.java:96) ~[tomcat-embed-core-8.5.51.jar!/:8.5.51]
at com.hundsun.fais.fhg.controller.FileController.downloadFile(FileController.java:146) [classes!/:?]
at sun.reflect.GeneratedMethodAccessor1161.invoke(Unknown Source) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_161]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_161]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) [spring-web-4.3.20.RELEASE.jar!/:4.3.20.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133) [spring-web-4.3.20.RELEASE.jar!/:4.3.20.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97) [spring-webmvc-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:849) [spring-webmvc-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:760) [spring-webmvc-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) [spring-webmvc-4.3.19.RELEASE.jar!/:4.3.19.RELEASE]
网上查找解决方式: nginx.conf 文件在 server中添加如下内容即可【亲测有效】
proxy_buffering on;
proxy_buffer_size 4k;
proxy_buffers 2 4k;
proxy_busy_buffers_size 4k;
proxy_temp_path /tmp/nginx_proxy_tmp 1 2;
proxy_max_temp_file_size 20M;
proxy_temp_file_write_size 8k;