【问题标题】:Unable to tunnel through proxy. Proxy returns HTTP/1.1 503 Service Unavailable无法通过代理进行隧道传输。代理返回 HTTP/1.1 503 服务不可用
【发布时间】:2017-08-11 18:19:23
【问题描述】:

我要连接内网服务器,需要连接的url是:

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

当我通过以下方式调用连接方法时:`

conn.connect();

我收到以下异常:

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

我该如何解决这个异常,我尝试了网上发布的许多解决方案,但没有任何运气。

【问题讨论】:

标签: java proxy ioexception tunneling


【解决方案1】:

我也遇到过类似的情况。我正在使用 maven jaxws-maven-plugin 插件并尝试从位于另一台服务器上的 WSDL 生成 java 代码。 问题是插件获取了环境变量httpproxy,而不是noproxy 变量。我通过手动添加它作为 JVM 参数解决了这个问题:

<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>

【讨论】:

    【解决方案2】:

    对我有帮助的是取消设置环境中的所有代理属性(http_proxy 等环境变量;-Dhttp.proxyHost=.. 等 java 属性令人惊讶地没有效果)。我的 URL (https://mycompany.example.com/service) 可以直接访问(因为它在内部网络上),但不能通过代理访问。

    因此检查服务所在的位置并检查与代理相关的环境变量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-02-11
      • 2013-07-01
      • 1970-01-01
      • 2020-04-18
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多