You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by "Zitony, Eyal" <ey...@hp.com> on 2014/11/17 17:45:24 UTC

Problem with Proxy settings

Hi all,

I'm using Jcloud in order to access HP Cloud object store.
I am able to connect and perform different operations, but the upload\download speed is poor and I need to set a proxy in order to overcome the speed issue.
I have followed the instructions I have found in http://jclouds.apache.org/reference/logging/#proxy
But when I'm setting the proxy configuration I'm getting the following error:
Exception in thread "main" org.jclouds.http.HttpResponseException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden" connecting to POST https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens HTTP/1.1<https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens%20HTTP/1.1>
        Iterable<Module> modules = ImmutableSet.<Module> of(
                new SLF4JLoggingModule());
        Properties overrides = new Properties();
        overrides.setProperty(PROPERTY_PROXY_HOST, PROXY_HOST);
        overrides.setProperty(PROPERTY_PROXY_PORT, PROXY_PORT);
        overrides.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
        BlobStoreContext context = ContextBuilder.newBuilder(PROVIDER)
                .credentials(identity, credential)
                //if i will remove the override, it will pass
                .overrides(overrides)
                .modules(modules)
                .buildView(BlobStoreContext.class);
        BlobStore blobStore = context.getBlobStore();
        //this is where the failure happens
        boolean exists = blobStore.containerExists(container);
        System.out.println("Container exists? " + exists );

The proxy configuration (host + port) that I'm using seems to be ok. I tried to use them by directly invoking a request using the apache HTTP client and it worked as expected
See the code bellow:
        HttpHost proxy = new HttpHost(hostname, port);
        DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
        HttpClient httpClient = HttpClients.custom()
               .setRoutePlanner(routePlanner)
               .build();
        HttpResponse httpResponse = httpClient.execute(request);

Did anyone encountered such issue or have any idea what can go wrong here?

Thanks

Eyal Zitony


RE: Problem with Proxy settings

Posted by "Zitony, Eyal" <ey...@hp.com>.
Hi Niraj,
Thank you for your help. 
I was able to use this URL (and to pass the authentication) when I used a REST client (chrome extension).
I guess that there is some kind of auto proxy detection in the browser that allow me to pass it.
If I'm understand correctly, the next step should be to ask my network admin to open this port in the proxy...
Is there by the way, an option to tell the driver to ignore the proxy when it calls the authentication URL? I actually need it only for the other services that uses the default port (does it make any sense?)

Eyal



-----Original Message-----
From: Niraj Tolia [mailto:ntolia@maginatics.com] 
Sent: יום ב 17 נובמבר 2014 19:09
To: user@jclouds.apache.org
Subject: Re: Problem with Proxy settings

Hi Eyal,

As you can see, the URL being accessed is https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens. Note the non-standard 35357 port. Combined with the fact that a number of corporate proxies only whitelist a limited set of ports, this might be the cause of your errors. From the same machine being used to test your code, I would see if you can get to that URL through a web browser (or curl) configured to use the proxy. You will get an error but it should not be a 403.

Cheers,
Niraj

On Mon, Nov 17, 2014 at 8:45 AM, Zitony, Eyal <ey...@hp.com> wrote:
> Hi all,
>
>
>
> I’m using Jcloud in order to access HP Cloud object store.
>
> I am able to connect and perform different operations, but the 
> upload\download speed is poor and I need to set a proxy in order to 
> overcome the speed issue.
>
> I have followed the instructions I have found in 
> http://jclouds.apache.org/reference/logging/#proxy
>
> But when I’m setting the proxy configuration I’m getting the following
> error:
>
> Exception in thread "main" org.jclouds.http.HttpResponseException: 
> Unable to tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden" 
> connecting to POST 
> https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens
> HTTP/1.1
>
>         Iterable<Module> modules = ImmutableSet.<Module> of(
>
>                 new SLF4JLoggingModule());
>
>         Properties overrides = new Properties();
>
>         overrides.setProperty(PROPERTY_PROXY_HOST, PROXY_HOST);
>
>         overrides.setProperty(PROPERTY_PROXY_PORT, PROXY_PORT);
>
>         overrides.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
>
>         BlobStoreContext context = ContextBuilder.newBuilder(PROVIDER)
>
>                 .credentials(identity, credential)
>
>                 //if i will remove the override, it will pass
>
>                 .overrides(overrides)
>
>                 .modules(modules)
>
>                 .buildView(BlobStoreContext.class);
>
>         BlobStore blobStore = context.getBlobStore();
>
>         //this is where the failure happens
>
>         boolean exists = blobStore.containerExists(container);
>
>         System.out.println("Container exists? " + exists );
>
>
>
> The proxy configuration (host + port) that I’m using seems to be ok. I 
> tried to use them by directly invoking a request using the apache HTTP 
> client and it worked as expected
>
> See the code bellow:
>
>         HttpHost proxy = new HttpHost(hostname, port);
>
>         DefaultProxyRoutePlanner routePlanner = new 
> DefaultProxyRoutePlanner(proxy);
>
>         HttpClient httpClient = HttpClients.custom()
>
>                .setRoutePlanner(routePlanner)
>
>                .build();
>
>         HttpResponse httpResponse = httpClient.execute(request);
>
>
>
> Did anyone encountered such issue or have any idea what can go wrong here?
>
>
>
> Thanks
>
>
>
> Eyal Zitony
>
>

Re: Problem with Proxy settings

Posted by Niraj Tolia <nt...@maginatics.com>.
Hi Eyal,

As you can see, the URL being accessed is
https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens. Note
the non-standard 35357 port. Combined with the fact that a number of
corporate proxies only whitelist a limited set of ports, this might be
the cause of your errors. From the same machine being used to test
your code, I would see if you can get to that URL through a web
browser (or curl) configured to use the proxy. You will get an error
but it should not be a 403.

Cheers,
Niraj

On Mon, Nov 17, 2014 at 8:45 AM, Zitony, Eyal <ey...@hp.com> wrote:
> Hi all,
>
>
>
> I’m using Jcloud in order to access HP Cloud object store.
>
> I am able to connect and perform different operations, but the
> upload\download speed is poor and I need to set a proxy in order to overcome
> the speed issue.
>
> I have followed the instructions I have found in
> http://jclouds.apache.org/reference/logging/#proxy
>
> But when I’m setting the proxy configuration I’m getting the following
> error:
>
> Exception in thread "main" org.jclouds.http.HttpResponseException: Unable to
> tunnel through proxy. Proxy returns "HTTP/1.1 403 Forbidden" connecting to
> POST https://region-a.geo-1.identity.hpcloudsvc.com:35357/v2.0/tokens
> HTTP/1.1
>
>         Iterable<Module> modules = ImmutableSet.<Module> of(
>
>                 new SLF4JLoggingModule());
>
>         Properties overrides = new Properties();
>
>         overrides.setProperty(PROPERTY_PROXY_HOST, PROXY_HOST);
>
>         overrides.setProperty(PROPERTY_PROXY_PORT, PROXY_PORT);
>
>         overrides.setProperty(PROPERTY_TRUST_ALL_CERTS, "true");
>
>         BlobStoreContext context = ContextBuilder.newBuilder(PROVIDER)
>
>                 .credentials(identity, credential)
>
>                 //if i will remove the override, it will pass
>
>                 .overrides(overrides)
>
>                 .modules(modules)
>
>                 .buildView(BlobStoreContext.class);
>
>         BlobStore blobStore = context.getBlobStore();
>
>         //this is where the failure happens
>
>         boolean exists = blobStore.containerExists(container);
>
>         System.out.println("Container exists? " + exists );
>
>
>
> The proxy configuration (host + port) that I’m using seems to be ok. I tried
> to use them by directly invoking a request using the apache HTTP client and
> it worked as expected
>
> See the code bellow:
>
>         HttpHost proxy = new HttpHost(hostname, port);
>
>         DefaultProxyRoutePlanner routePlanner = new
> DefaultProxyRoutePlanner(proxy);
>
>         HttpClient httpClient = HttpClients.custom()
>
>                .setRoutePlanner(routePlanner)
>
>                .build();
>
>         HttpResponse httpResponse = httpClient.execute(request);
>
>
>
> Did anyone encountered such issue or have any idea what can go wrong here?
>
>
>
> Thanks
>
>
>
> Eyal Zitony
>
>

Re: Problem with Proxy settings

Posted by Andrew Phillips <an...@apache.org>.
Hi Eyal

Could you enable wire and header logging [1] and then try to replicate  
this by trying the same request through the proxy that the jclouds is  
trying to make? Or is that what you tested already?

Also, are you using any of the jclouds HTTP drivers (okhttp or  
apachehc), or are you using the default java.net impelementation? You  
can see if you're using the drivers by having a look at the  
dependencies of your project.

Regards

ap

[1] http://jclouds.apache.org/reference/logging/#configure