出错场景
使用springcloud开发微服务,使用了easyPoi上传文件至文件服务器,上传成功后再进行解析,结果后台运行报错:
org.apache.catalina.connector.ClientAbortException: java.io.IOException: 你的主机中的软件中止了一个已建立的连接。
at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:356) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:825) ~[tomcat-embed-core-8.5.32.jar:8.5.32]
由于上传文件20万数据,还有逐个解析过滤,较耗内存。(如果大家有好的Excel上传过滤组件请推荐)
解决方案
系统网关中整合了hystrix,hystrix设置熔断的时间是60s, 当网关路由请求到下游服务的时候,下游的服务处理时间超过60s,导致网关触发超时,关闭链接,因此会出现上面的错误。修改配置文件,调整时间即可。
配置文件
ribbon: ReadTimeout: 10000 ConnectTimeout: 10000 hystrix: command: default: execution: isolation: thread: timeoutInMilliseconds: 120000