无法通过代理隧道.代理返回HTTP/1.1 503服务不可用

Man*_*eer 6 java proxy ioexception tunneling

我想连接到Intranet服务器,我需要连接的URL是:

URLConnection conn = new URL("https://mywebsite").openConnection();
Run Code Online (Sandbox Code Playgroud)

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

conn.connect();
Run Code Online (Sandbox Code Playgroud)

我收到以下异常:

java.io.IOException: Unable to tunnel through proxy. Proxy rerurns HTTP/1.1 503 Service Unavailable"
at sun.net.www.protocol.httpHttpURLConnection.doTunneling
Run Code Online (Sandbox Code Playgroud)

我怎么能解决这个例外,我已尝试过在网上发布的许多解决方案,但没有任何运气.

Jak*_*olý 0

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

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