title: POST API request timeout issue
body: <p>I'm trying to make a POST API call to our external API via the API PROXY. I'm facing some timeout issues while making a API call. I used below restTemplate to make a API request. But at the same time I've implemented the retry for the template in case of any timeouts. I can avoid this issue by retrying that api request again.But I would like to find out the root cause for that to completely resolve the issue.Can anyone help me with this</p>
  
  <p><strong>StackTrace:</strong></p>
  
  <pre><code>    org.springframework.web.client.ResourceAccessException: I/O error on POST request for "https://localhost:8080/test": Operation timed out (Read failed); nested exception is java.net.SocketException: Operation timed out (Read failed)
  
  </code></pre>
  
  <pre><code> private static final int HTTP_CLIENT_RETRY_COUNT = 3;
          private static final int MAXIMUM_TOTAL_CONNECTION = 10;
          private static final int MAXIMUM_CONNECTION_PER_ROUTE = 5;
          private static final int CONNECTION_VALIDATE_AFTER_INACTIVITY_MS = 10 * 1000;
          public static RestTemplate createRestTemplate(int connectionTimeoutMs, int readTimeoutMs, ObjectMapper objectMapper) {
              HttpClientBuilder clientBuilder = HttpClients.custom();
              PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
              // Set the maximum number of total open connections.
              connectionManager.setMaxTotal(MAXIMUM_TOTAL_CONNECTION);
              // Set the maximum number of concurrent connections per route, which is 2 by default.
              connectionManager.setDefaultMaxPerRoute(MAXIMUM_CONNECTION_PER_ROUTE);
              connectionManager.setValidateAfterInactivity(CONNECTION_VALIDATE_AFTER_INACTIVITY_MS);
              clientBuilder.setConnectionManager(connectionManager);
              clientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(HTTP_CLIENT_RETRY_COUNT, true, new ArrayList&lt;&gt;()) {
                  @Override
                  public boolean retryRequest(IOException exception, int executionCount, HttpContext context) {
                      LOGGER.info("Retry request, execution count: {}, exception: {}", executionCount, exception);
                      return super.retryRequest(exception, executionCount, context);
                  }
              });
              HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(clientBuilder.build());
              httpRequestFactory.setConnectTimeout(connectionTimeoutMs);
              httpRequestFactory.setConnectionRequestTimeout(readTimeoutMs);
              httpRequestFactory.setReadTimeout(readTimeoutMs);
              RestTemplate restTemplate = new RestTemplate(httpRequestFactory);
              List&lt;ClientHttpRequestInterceptor&gt; interceptors = new ArrayList&lt;ClientHttpRequestInterceptor&gt;();
              interceptors.add(new LoggingRequestInterceptor());
              restTemplate.setInterceptors(interceptors);
              restTemplate.setRequestFactory(new BufferingClientHttpRequestFactory(httpRequestFactory));
              MappingJackson2HttpMessageConverter messageConverter = restTemplate.getMessageConverters().stream().filter(MappingJackson2HttpMessageConverter.class::isInstance)
                      .map(MappingJackson2HttpMessageConverter.class::cast).findFirst().orElseThrow(() -&gt; new RuntimeException("MappingJackson2HttpMessageConverter not found"));
              messageConverter.setObjectMapper(objectMapper);
              restTemplate.getMessageConverters().stream().filter(StringHttpMessageConverter.class::isInstance).map(StringHttpMessageConverter.class::cast).forEach(a -&gt; {
                  a.setWriteAcceptCharset(false);
                  a.setDefaultCharset(StandardCharsets.UTF_8);
              });
              return restTemplate;
  }
  </code></pre>