Details
-
Test
-
Status: Closed
-
Major
-
Resolution: Invalid
-
4.3 Final
-
Linux, Virtual machine
Description
We have a multi threaded application which makes call to many http server. To make this http connection we are using HttpClient code with Pooling connectionManager. Recently we identified that all the threads in our application got stuck within the HttpClient code execution (Will paste/upload the thread dump soon.) as a result our application stopped running. Please let us know if this is not the right forum for this question.
1) Our code snippet is as follows.
HttpClient httpClient;
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create()
.register(HTTP_PROTOCOL, PlainConnectionSocketFactory.getSocketFactory())
.register(HTTPS_PROTOCOL, SSLConnectionSocketFactory.getSocketFactory()).build();
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(registry);
cm.setDefaultMaxPerRoute(10);
cm.setMaxTotal(10);
if (connectionParams != null && !connectionParams.isEmpty()) {
for (Map.Entry<String, List<String>> entry : connectionParams.entrySet()) {
List<String> attributes = entry.getValue();
boolean isSecure = false;
if (HTTPS_PROTOCOL.equals(attributes.get(0)))
HttpRoute route = new HttpRoute(new HttpHost(entry.getKey()), null, isSecure);
cm.setMaxPerRoute(route, 10);
}
}
httpClient = HttpClientBuilder.create().setConnectionManager(cm);
HttpGet request = new HttpGet("some uri");
request.setConfig(setConnectionTimeout(1000));
HttpResponse response = mHTTPClient.execute(request, new BasicHttpContext());