I am currently working on Spring Boot and our API is calling an application to get informations but we get randomly the error Connection prematurely closed BEFORE response; nested exception is reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
We watched the youtube video tited : How to Avoid Common Mistakes When Using Reactor Netty.
We also read the documentation about this error but we still don't understand how to solve the problem.
Unfortunately, we are not allowed to share our code.
Thank you for your answers
EDIT
We just created a new httpConnection from the webclient builder and the problem disappeared. I don't know why but the problem has been solved.
What solved the issue was to use an unpooled client of the ReactorClientHttpConnector
for the WebClient
object.
Here is the code to add in your WebClient
bean:
@Bean
WebClient webClient(...) {
...
return WebClient.builder().clientConnector(new ReactorClientHttpConnector(HttpClient.newConnection()
.compress(true)
.wiretap(true)))
...
}