kairosdb / kairosdb-client

Java Client for KairosDB
65 stars 67 forks source link

use client in springboot with @Async #72

Closed bigpws closed 5 years ago

bigpws commented 6 years ago

When I use this in a springboot project with async, erros shows like:

java.lang.IllegalStateException: Connection pool shut down
    at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.8.jar:4.4.8]
    at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191) ~[httpcore-4.4.8.jar:4.4.8]
    at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:257) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3]
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[httpclient-4.5.3.jar:4.5.3]
    at org.kairosdb.client.HttpClient.execute(HttpClient.java:107) ~[client-2.2.0.jar:na]
    at org.kairosdb.client.HttpClient.postData(HttpClient.java:76) ~[client-2.2.0.jar:na]
    at org.kairosdb.client.AbstractClient.pushMetrics(AbstractClient.java:87) ~[client-2.2.0.jar:na]
martin-g commented 6 years ago

Hi,

According to https://stackoverflow.com/a/34462361/497381 you can work it around with: HttpClients.custom().setConnectionManager(manager). setConnectionManagerShared(true).build();

And according to https://stackoverflow.com/a/25894224/497381 it is fixed in Apache HttpClient 4.4 series.

On Fri, Jun 1, 2018 at 8:38 AM, Sun Chen notifications@github.com wrote:

When I use this in a springboot project with async, erros shows like:

java.lang.IllegalStateException: Connection pool shut down at org.apache.http.util.Asserts.check(Asserts.java:34) ~[httpcore-4.4.8.jar:4.4.8] at org.apache.http.pool.AbstractConnPool.lease(AbstractConnPool.java:191) ~[httpcore-4.4.8.jar:4.4.8] at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.requestConnection(PoolingHttpClientConnectionManager.java:257) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:176) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83) ~[httpclient-4.5.3.jar:4.5.3] at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108) ~[httpclient-4.5.3.jar:4.5.3] at org.kairosdb.client.HttpClient.execute(HttpClient.java:107) ~[client-2.2.0.jar:na] at org.kairosdb.client.HttpClient.postData(HttpClient.java:76) ~[client-2.2.0.jar:na] at org.kairosdb.client.AbstractClient.pushMetrics(AbstractClient.java:87) ~[client-2.2.0.jar:na]

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kairosdb/kairosdb-client/issues/72, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOKQg5JRLGEXdFNQS5XD0015nf-SQoUks5t4NNVgaJpZM4UWIXs .

jsabin commented 5 years ago

Related to #77.

jsabin commented 5 years ago

Fixed in commit b9fe5812e96d195ac0c0da3e22e3a658c57d948b.