Connection has been closed BEFORE response, while sending request body when uploading large file (size: 9 MO)
See original GitHub issueI have spring boot application running behind a spring cloud gateway, when I upload large file (size: 10 MO) via a postman request, I get the following error:
reactor.netty.http.client.PrematureCloseException: Connection has been closed BEFORE response, while sending request body
Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint ⇢ org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint ⇢ HTTP POST "/hi" [ExceptionHandlingWebHandler]
Stack trace:
spring boot application Controller:
@PostMapping(value = "hi")
public String postHi(@RequestHeader HttpHeaders headers) {
return request.getHeader("Content-Length");
}
Spring cloud gateway route configuration :
server:
port: 8101
spring:
cloud:
gateway:
routes:
- id: hi
uri: http://localhost:8080/hi
predicates:
- Path=/hi/**
Steps to Reproduce
Here is an example to reproduce the issue https://github.com/jemmali-git/examples.git
- Reactor version used: 0.9.1RELEASE
- spring cloud gateway version: 2.2.0.RELEASE
- Other relevant libraries versions (eg.
netty, …): - JVM version (
javar -version): 1.8 - OS and version : Windows 10 Pro
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:10 (5 by maintainers)
Top Results From Across the Web
nginx - client request body is buffered to a temporary file
It means that the size of the uploaded file was larger than the in-memory buffer reserved for uploads. The directive client_body_buffer_size ...
Read more >c# - Big files uploading (WebException: The connection was ...
WebException was unhandled by user code Message="The underlying connection was closed: The connection was closed unexpectedly.
Read more >Upload Media | DV360 API - Google Developers
For this initiating request, the body is either empty or it contains the metadata only; you'll transfer the actual contents of the file...
Read more >core - Apache HTTP Server Version 2.4
This directive enables operating system specific optimizations for a listening socket by the Protocol type. The basic premise is for the kernel to...
Read more >File System API - Egnyte for Developers
The response is a HTTP 200 OK Code that confirms that the file (or folder) has been moved to the destination folder. Sample...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You might be hitting some of these limitations https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html
I see that the target application uses Spring MVC. When the limitations above are met Tomcat will reset the connection which will lead to the exception
Connection has been closed BEFORE response, while sending request bodythat you see.@violetagg see https://github.com/reactor/reactor-netty/issues/1062