Hello Experts,  We have been running Apache Async Http Client in Product to
Post Events to Splunk & Datadog Third-Party Systems. Most of the times it
works well but when there was some Connection Closed Exception happens for
a particular endpoint, Client is continuously getting task cancelled error
which is resulting in the data loss from our side.


Context:
We run the AsyncClient in Container, Configuration of Container: 2 CPUs, 7
GB memory & 1GB disk.

The moment AsyncHttpClient receives  " Failed to post log to destination
EndPoint :  https://abcde.com/v1/input/jskjdhk ,  *Error Msg: Connection
closed " *the all subsequent calls getting task cancelled by http client.

What's wrong with the client configuration? Am i missing something?

Client Settings:

public static final RequestConfig.Builder requestConfigBuilder =
RequestConfig.custom()
            .setConnectTimeout(DEFAULT_CONNECT_TIMEOUT_MILLIS) // 10 seconds
            .setSocketTimeout(DEFAULT_SOCKET_TIMEOUT_MILLIS) // 10 seconds

.setConnectionRequestTimeout(DEFAULT_CONNECTION_REQUEST_TIMEOUT_MILLIS); //
10 seconds

public static final ConnectionConfig connectionConfig =
ConnectionConfig.custom()
           .setBufferSize(DEFAULT_BUFFER_SIZE)
           .setMessageConstraints(messageConstraints)
           .setFragmentSizeHint(DEFAULT_BUFFER_SIZE)
           .build();

final PoolingNHttpClientConnectionManager mgr = new
PoolingNHttpClientConnectionManager(ioreactor, registry);
       mgr.setDefaultConnectionConfig(connectionConfig);
       mgr.setMaxTotal(DEFAULT_MAX_CONN_TOTAL); // 500
       mgr.setDefaultMaxPerRoute(DEFAULT_MAX_CONN_PER_ROUTE); // 25
       mgr.closeExpiredConnections();

   final HttpAsyncClientBuilder httpClientBuilder =
HttpAsyncClientBuilder.create()

 .setDefaultRequestConfig(requestConfigBuilder.build())
                         .setMaxConnPerRoute(DEFAULT_MAX_CONN_PER_ROUTE)
//25
                         .setMaxConnTotal(DEFAULT_MAX_CONN_TOTAL)//500
                         .setDefaultConnectionConfig(connectionConfig)
                         .setConnectionManager(mgr)
                         .setSSLContext(getSSLContext())
                         .setSSLHostnameVerifier(hostNameVerifier)
                         .disableConnectionState()
                         .disableAuthCaching()
                         .disableCookieManagement()
                         .useSystemProperties();
   CloseableHttpAsyncClient httpClient = httpClientBuilder.build();
    httpClient.start();


<dependency>
   <groupId>org.apache.httpcomponents</groupId>
   <artifactId>*httpasyncclient*</artifactId>
   <version>4.1.4</version>
</dependency>

--Senthil

Reply via email to