Thanks!
I went ahead with the first implementation.

Vicky
________________________________________
From: Oleg Kalnichevski <ol...@apache.org>
Sent: Friday, June 10, 2016 10:55 AM
To: httpclient-users@hc.apache.org
Subject: Re: How to retrieve server ip of the connected connections

On Thu, 2016-06-09 at 19:40 +0000, Vicky Singh wrote:
>
>
>  I am using PoolingHttpClientConnectionManager to create connections. I would 
> like to get what IP address my connections resolve to. Is there a API that I 
> can use.
> I need it for reporting and also to drop connections if I think connected IP 
> is not the best IP address. I found this 
> https://issues.apache.org/jira/browse/HTTPCLIENT-656
>
> Summary of my code,
> PoolingHttpClientConnectionManager connMgr = new 
> PoolingHttpClientConnectionManager(socketFactoryRegistry);        ....// 
> build custom http client . ...        Set<HttpRoute> hosts = 
> connMgr.getRoutes();        for (HttpRoute r: hosts) {            InetAddress 
> ip = r.getTargetHost().getAddress();            break;        }
> The above code gets an IP only if HttpHost was created using IP in 
> constructor . From documentation of  HttpHost.getAddress() Returns the inet 
> address if explicitly set by a constructor, null otherwise.
>

There are different ways to approach the problem
(1) Have full control over hostname resolution by using a custom
DnsResolver
(2) Get hold of active connections from a custom subsclass of
HttpRequestExecutor

Oleg




---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscr...@hc.apache.org
For additional commands, e-mail: httpclient-users-h...@hc.apache.org

Reply via email to