Getting ConnectionPoolTimeoutException while calling Elastic search cluster

Hello,
We are getting ConnectionPoolTimeoutException while calling elastic search for update and get query. We are using aws elastic search services. We are using Jest client and configuration are below.

 public final class JestClientFactory {

    private JestClientFactory() {
    }

    public static final int READ_TIME_OUT = 60000;
    public static final int MAX_TOTAL_CONNS = 40;
    public static final int DEFAULT_MAX_TOTAL_CONNECTION_PER_ROUTE = 4;

    public static JestClient getClient(final String esEndpoint, final String awsRegion, final String odinMaterialSet) {
        final HttpClientConfig httpClientConfig = new HttpClientConfig.Builder(esEndpoint)
                                                                      .multiThreaded(true)
                                                                      .readTimeout(READ_TIME_OUT)
                                                                      .defaultMaxTotalConnectionPerRoute(DEFAULT_MAX_TOTAL_CONNECTION_PER_ROUTE)
                                                                      .maxTotalConnection(MAX_TOTAL_CONNS)
                                                                      .build();

        final AESClientFactory aesClientFactory = new AESClientFactory(getAwsCredentialsProvier(odinMaterialSet),
                awsRegion);
        aesClientFactory.setHttpClientConfig(httpClientConfig);
        final JestClient jestClient = aesClientFactory.getObject();
        return jestClient;
    }

    private static AWSCredentialsProvider getAwsCredentialsProvier(final String odinMaterialSetValue) {
        return new OdinAWSCredentialsProvider(odinMaterialSetValue);
    }
}

Complete logs for error which we are getting are below -

application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:Caused by: org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting for connection from pool
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.leaseConnection(PoolingHttpClientConnectionManager.java:314) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.conn.PoolingHttpClientConnectionManager$1.get(PoolingHttpClientConnectionManager.java:280) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:190) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[Apache-HttpComponents-HttpClient-4.5.x.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at io.searchbox.client.http.JestHttpClient.executeRequest(JestHttpClient.java:109) ~[Jest-2.0.3.jar:?]
application.log.2020-08-06-16.es-analytics-eu-prod-1a-1106f343.eu-west-1.amazon.com.gz:	at io.searchbox.client.http.JestHttpClient.execute(JestHttpClient.java:56) ~[Jest-2.0.3.jar:?]
  1. Can anyone help to provide better configuration details and how I can avoid this exception?
  2. Also not able to find meaning for defaultMaxTotalConnectionPerRoute. Please provide info about this.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.