[
https://issues.apache.org/jira/browse/HTTPCLIENT-839?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12693797#action_12693797
]
Ortwin Glück commented on HTTPCLIENT-839:
-----------------------------------------
Anyway this connection manager should respect a timeout for getConnection().
Waiting indefinitely is no good.
> ThreadSafeClientConnManager blocks forever on getConnection()
> -------------------------------------------------------------
>
> Key: HTTPCLIENT-839
> URL: https://issues.apache.org/jira/browse/HTTPCLIENT-839
> Project: HttpComponents HttpClient
> Issue Type: Bug
> Components: HttpConn
> Affects Versions: 4.0 Beta 2
> Environment: Android 1.1 R1
> Reporter: Matthias
>
> I have set up a HttpClient object with a ThreadSafeClientConnManager as
> follows:
> BasicHttpParams httpParams = new BasicHttpParams();
> ConnManagerParams.setMaxTotalConnections(httpParams, 10);
> HttpProtocolParams.setVersion(httpParams, HttpVersion.HTTP_1_1);
> HttpProtocolParams.setUserAgent(httpParams, HTTP_USER_AGENT);
> SchemeRegistry schemeRegistry = new SchemeRegistry();
> int port = prefs.isDebugMode() ? 3001 : 80;
> schemeRegistry.register(new Scheme("http",
> PlainSocketFactory.getSocketFactory(), port));
> ThreadSafeClientConnManager cm = new ThreadSafeClientConnManager(
> httpParams, schemeRegistry);
> this.httpClient = new DefaultHttpClient(cm, httpParams);
> In one of my Android activities, I upload photos asynchronously using this
> client (i.e. from different threads). When POST-ing the data,
> ThreadSafeClientConnManager.getConnection() always blocks eternally during
> the third upload, waiting for a connection to become free (why does it wait
> anyway when I told it to use up to 10 connections, not just 2?). ANY
> subsequent attempt to call execute() on that client will block on that
> unreleased lock forever, rendering the whole client object useless.
> Here is the code I use to dispatch the request:
> private void sendPostRequest(String url, HttpEntity payload)
> throws ConnectionFailedException, HttpResponseException {
> try {
> HttpPost request = new HttpPost(url);
> request.setEntity(payload);
> request.setHeader(HTTP_CONTENT_TYPE,
> payload.getContentType().getValue());
> oauthConsumer.sign(url, request);
> HttpResponse response = httpClient.execute(request,
> new BasicHttpContext());
> validatePostResponse(response);
> } catch (HttpResponseException e) {
> throw e;
> } catch (Exception e) {
> throw new ConnectionFailedException(e);
> }
> }
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]