0
点赞
收藏
分享

微信扫一扫

#如何解决Tomcat中的应用java.io.IOException您的主机中的一个软件中止了一个已建立的连接#

丹柯yx 2024-09-06 阅读 22

错误描述

其实就是因为各种原因(比如你调试打的断点,网速等原因导致连接时间超过了默认设置的超时时间tomcat就将该连接断开)

org.apache.catalina.connector.ClientAbortException: java.io.IOException: 您的主机中的软件中止了一个已建立的连接。

1

在tomcat出现这个错误是由于客户端发出请求后,还没等服务器响应就断开连接,有可能是网断了,也有可能是服务端问题 (如调试时间过长导致响应时间超时)。

在Tomcat中配置了一个连接超时时间connectionTimout,如果在这个时间之后客户端不还未得到服务器端的响应,就会主动断开连接,产生上述异常,Tomcat中默认超时时间是20秒,我们一般设置为60秒,从而避免后台程序处理时间太长导致断开连接。

设置方法

方法一:

进入Tomcat中conf目录,打开server.xml文件,找到配置端口的地方

connectionTimeout="20000"

redirectPort="8443" />

1

2

3

方法二:

在yml配置文件中:

server:

tomcat:

accept-count: 1000

max-connections: 2000

max-threads: 300

min-spare-threads: 50

uri-encoding: UTF-8

max-http-post-size: 100MB

accesslog:

enabled: true

port: 8008

connection-timeout: 60000

servlet:

context-path: /zlgmces

compression:

enabled: true

http2:

enabled: true

/**
- 获取license 去除水印
- @return
/**
- excel 转为pdf 输出。
- 
- @param sourceFilePath  excel文件
- @param desFilePathd  pad 输出文件目录
*/
public static void excel2pdf(String sourceFilePath, String desFilePathd ){
// 验证License 若不验证则转化出的pdf文档会有水印产生
if (!getLicense()) {
return;
}
try {
Workbook wb = new Workbook(sourceFilePath);// 原始excel路径
FileOutputStream fileOS = new FileOutputStream(desFilePathd);
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();
pdfSaveOptions.setOnePagePerSheet(true);
int[] autoDrawSheets={3};
//当excel中对应的sheet页宽度太大时,在PDF中会拆断并分页。此处等比缩放。
//            autoDraw(wb,autoDrawSheets);
int[] showSheets={0};
//隐藏workbook中不需要的sheet页。
printSheetPage(wb,showSheets);
wb.save(fileOS, pdfSaveOptions);
fileOS.flush();
fileOS.close();
System.out.println("完毕");
} catch (Exception e) {
  e.printStackTrace();
}

}

举报

相关推荐

0 条评论