Unexpected EOF read on the socket问题解决
程序员文章站
2022-03-02 14:38:55
...
文件上传报错java.io.EOFException: Unexpected EOF read on the socket 问题解决
问题原因
看字面意思,说是文件还没到末尾就被客户端中断,可是文件已经被上传到了服务器,并且信息也已经返回,为什么会这样?猜想是超出tomcat文件连接时间了,就被跳转
解决方案
我用的是Spring Boot项目,可以直接在application配置文件里加上一个tomcat连接时长
server.connectionTimeout =180000
再加一个文件配置类,写上一段代码
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
factory.setMaxFileSize(102400000);
factory.setMaxRequestSize(102400000);
String location = System.getProperty("user.dir") + "/data/tmp";
File tmpFile = new File(location);
if (!tmpFile.exists()) {
tmpFile.mkdirs();
}
factory.setLocation(location);
return factory.createMultipartConfig();
}
完美解决
上一篇: 关于初始化
推荐阅读
-
java.io.EOFException: Unexpected EOF read on the socket
-
解决文件上传 java.io.EOFException: Unexpected EOF read on the socket问题
-
Unexpected EOF read on the socket
-
记录:java.io.EOFException: Unexpected EOF read on the socket
-
org.apache.catalina.connector.ClientAbortException: java.io.EOFException: Unexpected EOF read on the
-
SpringBoot文件上传:java.io.EOFException: Unexpected EOF read on the socket
-
SpringBoot - Processing of multipart/form-data request failed. Unexpected EOF read on the socket
-
java.io.EOFException: Unexpected EOF read on the socket
-
文件上传错误:java.io.EOFException: Unexpected EOF read on the socket
-
SpringBoot 解决文件上传 java.io.EOFException: Unexpected EOF read on the socket问题