Reputation: 346
How to use the Apache httpclient 4.3 and PoolingHttpClientConnectionManager and pass the ConnectTimeOut and ReadTimeOut for each request.
For example, If I have the CloseableHttpClient as Singleton and using the PoolingHttpClientConnection to obtain the connection, for each request I make , I want to send different timeout values based on the target host
ie. HostA 10 Seconds , Host B 5 seconds etc
Please advise.
Upvotes: 2
Views: 4908
Reputation: 27538
HttpGet get1 = new HttpGet("http://hosta/");
RequestConfig config1 = RequestConfig.custom().setSocketTimeout(10000).build();
get1.setConfig(config1);
HttpGet get2 = new HttpGet("http://hostb/");
RequestConfig config2 = RequestConfig.custom().setSocketTimeout(5000).build();
get2.setConfig(config2);
Upvotes: 4