"Connection reset by peer" for Java HttpClient request

1.6k views Asked by At

I'm using SpringBoot with JDK 11. This application is deployed on a container (AWS).

Into my REST Controllers I need to call internally external REST api services (using TLS 1.2) I'm using java.net.http.HttpClient for this.

httpClient = HttpClient.newHttpClient();

(I'm using only one httpClient for all requests)

Sometimes (randomically) these requests fail. Into my logs I see as cause of this problem:

Connection reset by peer

This is strange for me. As already explained, this error does not happen systematically.

I analysed my code but I don't notice anything wrong.

Any suggestion?

Is the HttpClient initialization correct?

Is possible that the cause it's related to my code or from the external services?

Any suggestions are welcome.

0

There are 0 answers