English is not my native language, please excuse typing errors. I guess your problem is that you forget close the connection when exception happened. If so, you should put the close method in the finally block. If connection doesn’t released, the connection pool will be fill up.
发件人: SenthilKumar K 发送时间: 2020年8月28日 16:56 收件人: httpclient-users@hc.apache.org 抄送: Senthil kumar 主题: Task Cancelled by HttpClient - 4.1.4 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