Shisoft
Shisoft

Reputation: 4245

how to wait connection?

I always got

java.lang.IllegalStateException: Invalid use of SingleClientConnManager: connection still allocated. Make sure to release the connection before allocating another one.

Exception.I tried to use abort after use but still remains.

Is there any way to wait for the connection to complete?

Upvotes: 1

Views: 381

Answers (2)

user638455
user638455

Reputation:

If you are using the http client from multiple threads you need to use the ThreadSafeClientConnManager.

http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.html

Upvotes: 1

Jon Skeet
Jon Skeet

Reputation: 1500475

You should call conn.releaseConnection after you've finished with the first request, which will allow you to get another handle to the same underlying connection for the next request.

If that's not the problem, you need to give more details - your question is fairly unclear at the moment.

Upvotes: 1

Related Questions