解决文件上传 : Unexpected EOF read on the socket问题

时间:2025-02-09 17:20:03

解决springboot 文件上传 : Unexpected EOF read on the socket问题

问题原因,上传文件还没到末尾就被客户端中断,是超出tomcat文件连接时间了,就被跳转。

解决方案

在配置文件里加上一个tomcat连接时长

server:
  connection-timeout: 18000000

添加文件配置类


@Configuration
public class CommonConfig {

    @Bean
    public MultipartConfigElement multipartConfigElement() {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        (1024 * 1024); // 限制上传文件大小
        return ();
    }
}