7

I want to connect to an intranet server, the url that I need to connect is:

URLConnection conn = new URL("https://mywebsite").openConnection();

When I reach to the connect method call through:`

conn.connect();

I'm getting the following exception:

java.io.IOException: Unable to tunnel through proxy. Proxy rerurns HTTP/1.1 503 Service Unavailable"
at sun.net.www.protocol.httpHttpURLConnection.doTunneling

How can I solve this exception, I have tried many solutions published on the net, but without any luck.

ManKeer
  • 543
  • 2
  • 6
  • 27
  • See https://stackoverflow.com/questions/44328077/unable-to-tunnel-through-proxy-proxy-returns-http-1-1-503-service-unavailable for a similar but somewhat different case. – Jakub Holý Oct 04 '18 at 09:39

2 Answers2

0

What helped to me was to unset all proxy properties in the environment (http_proxy etc env variables; java properties such as -Dhttp.proxyHost=.. had, surprisingly, no effect). My URL (https://mycompany.example.com/service) was accessible directly (because it was on the internal network) but not through the proxy.

So check where the service lives and check for proxy-related environment variables.

Jakub Holý
  • 6,019
  • 3
  • 33
  • 33
0

I hade a similar case. I'm using the maven jaxws-maven-plugin plugin and trying to generate java code from a WSDL laying on another server. The problem was that the plugin is picking up the environment variable httpproxy, but not the noproxy variable. I solved that by adding it manually as a JVM argument:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.4.1</version>
<executions>
    <execution>
        <id>wsdltoJava</id>
        <goals>
            <goal>wsimport</goal>
        </goals>
        <configuration>
            <wsdlUrls>
                <wsdlUrl>https://someService.yourcompany.net/Service/Service?wsdl</wsdlUrl>
            </wsdlUrls>
            <vmArgs>
                <vmArg>-Dhttp.nonProxyHosts=*.yourcompany.net</vmArg>
            </vmArgs>
            <keep>true</keep>
            <packageName>com.yourcompany.package</packageName>
            <sourceDestDir>your/target/directory</sourceDestDir>
        </configuration>
    </execution>
</executions>

Guillermo
  • 764
  • 6
  • 15