connections not released (using apache httpclient low level transport)

389 views
Skip to first unread message

Paolo

unread,
Feb 3, 2011, 5:42:44 AM2/3/11
to google-api-java-client
Hello,

I have a class using Fusion API.
I do http calls using
com.google.api.client.http.HttpRequest.execute(); I am using
httpclient 4.0.3

From my tests it is evident that when HttpResponseException occurs,
the http connection is not released properly.
This happens even though I always consume the content, via ignore().

So after 2 exceptions occur, the pool times out waiting for a
connection.

Here's a snippet of the log:
------------------------
DEBUG - hreadSafeClientConnManager - Get connection: HttpRoute[{}-
>http://www.google.com], timeout = 20000
DEBUG - ConnPoolByRoute - [HttpRoute[{}->http://
www.google.com]] kept alive: 1, issued: 2, allocated: 3 out of 20
DEBUG - ConnPoolByRoute - No free connections [HttpRoute[{}-
>http://www.google.com]][null]
DEBUG - ConnPoolByRoute - Available capacity: 0 out of 2
[HttpRoute[{}->http://www.google.com]][null]
DEBUG - ConnPoolByRoute - Need to wait for connection
[HttpRoute[{}->http://www.google.com]][null]
DEBUG - FusionTablesAccessor - Failed executing the http request
to Google Fusion
org.apache.http.conn.ConnectionPoolTimeoutException: Timeout waiting
for connection
at
org.apache.http.impl.conn.tsccm.ConnPoolByRoute.getEntryBlocking(ConnPoolByRoute.java:
348)
at org.apache.http.impl.conn.tsccm.ConnPoolByRoute
$1.getPoolEntry(ConnPoolByRoute.java:228)
at org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager
$1.getConnection(ThreadSafeClientConnManager.java:171)
at
org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:
390)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
641)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
576)
at
org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:
554)
at
com.google.api.client.apache.ApacheHttpRequest.execute(ApacheHttpRequest.java:
47)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:
207)
[...]

Yaniv Inbar (יניב ענבר)

unread,
Feb 3, 2011, 7:53:26 AM2/3/11
to google-api-...@googlegroups.com
Thanks for reporting the problem.  Is your application multi-threaded?  Which version of the google-api-java-client are you using?

I ask because there was a bug fixed in version 1.2.2-alpha to support multi-threaded applications using Apache HTTP client.  Another developer has reported that this fixed it for them, but I'm not confident if it solves completely solves it.

Yaniv Inbar
Senior Software Engineer
Google Inc.

Paolo

unread,
Feb 3, 2011, 9:30:39 AM2/3/11
to google-api-java-client
I have a FusionTablesAccessor class doing requests, it's a spring
singleton bean.
And I am using google-api-java-client 1.2.2-alpha

I also tried using a custom low level transport so that I use a
SingleClientConnManager, but it seems the connection is not released
either.

cheers

Paolo

unread,
Feb 6, 2011, 6:06:58 AM2/6/11
to google-api-java-client
I changed my class to use directly an HttpClient instance (the
DefaultHttpClient).

I always consume the content when I get back an HttpEntity, it works
fine and releases the connection.
So I think the problem is not multi-threading specific, or I must be
missing something otherwise.

hope this helps
cheers
Reply all
Reply to author
Forward
0 new messages