无法通过代理建立隧道。代理返回“HTTP/1.1 503 服务不可用”

Pra*_*kta 5 java proxy

这是我的 HTTPGet 方法代码。但我收到以下错误。

响应代码:503 线程“main”中的异常 java.io.IOException:无法通过代理建立隧道。代理返回“HTTP/1.1 503 服务不可用”

我的代码是

Proxy objProxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(
                "proxyname", port_no));
        String url = "any url";

        URL obj = new URL(url);
        System.out.println("URL" + obj.toString());

        HttpURLConnection con = (HttpURLConnection) obj.openConnection(objProxy);

        // optional default is GET
        con.setRequestMethod("GET");

        Authenticator.setDefault(new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication("username", "password"
                        .toCharArray());
            }
        });
        System.out.println("Proxy Used: " + con.usingProxy());
        int responseCode = con.getResponseCode();
        System.out.println("\nSending 'GET' request to URL : " + url);
        System.out.println("Response Code : " + responseCode);

        BufferedReader in = new BufferedReader(new InputStreamReader(
                con.getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        // print result
        System.out.println(response.toString());
Run Code Online (Sandbox Code Playgroud)

尝试设置

System.setProperty("jdk.http.auth.tunneling.disabledSchemes", "");

在代码中通过查看另一个问题句柄中的解决方案。但它仍然显示相同的错误。

任何替代解决方案?