We are using Apache HttpClient library to call HTTP REST endpoints in the Spring application. We are getting "Connection reset" error frequently now a days, We did not have any issue earlier but the error started appearing now, we see 1 to 5 out of 100 requests get this error. The code we are using to create HttpClient looks like this:
RequestConfig requestConfig = RequestConfig.custom()
.setConnectionRequestTimeout(connReqTimeoutInMillis)
.setConnectTimeout(connTimeoutInMillis)
.setSocketTimeout(socketTimeoutInMillis)
.build();
CloseableHttpClient client = HttpClientBuilder.create()
.setDefaultRequestConfig(requestConfig)
.setMaxConnPerRoute(numberOfConnections)
.setSSLSocketFactory(new SSLConnectionSocketFactory(SSLContext.getDefault(),
new String[]{"TLSv1.2"}, null,
ALLOW_ALL_HOSTNAME_VERIFIER)).build();
We are using this client object across the application. So the remote calls that we are making do not have any issues, as there are some calls we make from one service to another service within the project, those also have the same issue sometimes. This issue occurs for all HTTP method calls.
Exact error:
- javax.net.ssl.SSLException: java.net.SocketException: Connection reset
- Suppressed: java.net.SocketException: Broken pipe (Write failed)
Could someone please help here, Thanks for your help!