Search code examples
javaspringrestspring-web

Error thrown when call post rest api with big data size


I have a problem. When I call a post rest api with big data (about 35 megabyte in body) this exception is thrown:

org.springframework.web.client.ResourceAccessException: 
     I/O error on POST request for "x": Software caused connection abort: recv failed; 
     nested exception is java.net.SocketException: 
     Software caused connection abort: recv failed

I am using wildfly web server and set maxPostSize=250961630, but it is not working.

Can someone help me, please?


Solution

  • The problem solved. In Spring boot,you must define multipartConfigElement bean and set value on setMaxFileSize and setMaxRequestSize properties.The code is:

    @Bean
    public MultipartConfigElement multipartConfigElement()
    {
        MultipartConfigFactory factory = new MultipartConfigFactory();
        factory.setMaxFileSize("1000MB");
        factory.setMaxRequestSize("1000MB");
        return factory.createMultipartConfig();
    }