hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Kalnichevski <ol...@apache.org>
Subject Re: Facing connection issues with http proxy in HttpClient4.3.1
Date Thu, 21 Nov 2013 08:48:55 GMT
On Wed, 2013-11-20 at 19:30 +0530, Dhruvakumar P G wrote:
> Hello,
> 
> I have upgraded HttpClient library from 4.0.1 to 4.3.1 and using it in 
> my web application for communicating to twitter REST API service. If I 
> don't set the http proxy in web container(Glassfish2.1) and try 
> connecting to twitter from my home network, HttpClient is able to make 
> https requests to twitter service.
> But if I set the http proxy in Glassfish, and try connecting to twitter 
> from corporate network(I must set the proxy given by company to talk to 
> internet), HttpClient is not able to make https requests to twitter service.
> I have been trying out different ways but none of them works :
> 1. If I set the proxy in Request configuration : 
> requestConfigBuilder.setProxy(proxy). It 
> throws*org.apache.http.conn.HttpConnectionHostException : Connection 
> timedout*
> 2. If I set the proxy in Http client object : 
> httpClientBuilder.setProxy(proxy). It throws 
> *org.apache.http.conn.UnsupportedSchemeException :  http protocol is not 
> supported*
> 3. Setting the proxy the following way also didn't work :
>                  DefaultProxyRoutePlanner routePlanner = new 
> DefaultProxyRoutePlanner(proxy); 
> httpClientBuilder.setRoutePlanner(routePlanner)
> 
> What am I missing here ? Is there any other way that I can try out to 
> setup proxy ?
> 

Try this

---
CloseableHttpClient client = HttpClients.custom()
        .setRoutePlanner(new
SystemDefaultRoutePlanner(ProxySelector.getDefault()))
        .build();
---

Oleg



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
For additional commands, e-mail: dev-help@hc.apache.org


Mime
View raw message