我在我的一个程序中收到了主题提到的错误代码。我在 Stackoverflow 上四处寻找解决方案,并尝试遵循Ilana Platonov和PPr报告的问题的建议。不幸的是,这些并没有解决错误。
作为下一步,我只是尝试运行Ilana Platonov中提供的代码以及解决方案(在那里接受)。我的代码:包示例;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.Authenticator;
import java.net.HttpURLConnection;
import java.net.InetSocketAddress;
import java.net.PasswordAuthentication;
import java.net.Proxy;
import java.net.URL;
public class MyProxyPass {
public MyProxyPass( String proxyHost, int proxyPort, final String userid, final String password, String url ) {
try {
/* Create a HttpURLConnection Object and set the properties */
URL u = new URL( url );
Proxy proxy = new Proxy( Proxy.Type.HTTP, new InetSocketAddress( proxyHost, proxyPort ) );
HttpURLConnection uc = (HttpURLConnection) u.openConnection( proxy );
Authenticator.setDefault( new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
if (getRequestorType().equals( RequestorType.PROXY )) {
return new PasswordAuthentication( userid, password.toCharArray() );
}
return super.getPasswordAuthentication();
}
} );
uc.connect();
/* Print the content of the url to the console. */
showContent( uc );
}
catch (IOException e) {
e.printStackTrace();
}
}
private void showContent( HttpURLConnection uc ) throws IOException {
InputStream i = uc.getInputStream();
char c;
InputStreamReader isr = new InputStreamReader( i );
BufferedReader br = new BufferedReader( isr );
String line;
while ((line = br.readLine()) != null) {
System.out.println( line );
}
}
public static void main( String[] args ) {
String proxyhost = "xxx.xxx.xx.xx";
int proxyport = xxxx;
final String proxylogin = "JOKER";
final String proxypass = "passxxx";
String url = "http://www.google.de";
String surl = "https://www.google.de";
System.setProperty("javax.net.ssl.trustStore", "C:\\Users\\JOKER\\Documents\\eclipse-jee-photon-R-win32\\eclipse");
System.setProperty("javax.net.ssl.trustStorePassword", "changeit");
//new MyProxyPass( proxyhost, proxyport, proxylogin, proxypass, url ); // uncomment this line to see that the https request works!
//System.out.println( url + " ...ok" ); // uncomment this line to see that the https request works!
new MyProxyPass( proxyhost, proxyport, proxylogin, proxypass, surl );
System.out.println( surl + " ...ok" );
}
}
但是,我仍然收到其他人报告的相同错误:
java.io.IOException: Unable to tunnel through proxy. Proxy returns "HTTP/1.1 407 Proxy Authentication Required"
https://www.google.de ...ok
at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2124)
at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.connect(HttpsURLConnectionImpl.java:153)
at examples.MyProxyPass.<init>(MyProxyPass.java:32)
at examples.MyProxyPass.main(MyProxyPass.java:63)
什么对别人有用,对我没用:
经常给出的关于将变量 jdk.http.auth.tunneling.disabledSchemes 和 jdk.http.auth.proxying.disabledSchemes 设置为空白的建议不起作用。我在 ..\Java\jdk1.8.0_112\jre\lib\net.properties 文件中将这些设置为空白。
使用Andreas Panagiotidis提出的各种 JVM Args也无济于事。
- 从https://bugs.eclipse.org/bugs/show_bug.cgi?id=422665我还尝试排除可能存在冲突的 HTTP 库。-Dorg.eclipse.ecf.provider.filetransfer.excludeContributors=org.eclipse.ecf.provider.filetransfer.httpclient4
我在用:
- Eclipse IDE 光子发布 (4.8.0),
- java 版本“1.8.0_112”(构建 1.8.0_112-b15)
- 视窗 10
- 我在公司代理背后,花了整整两天时间没有成功。:(
让我知道我是否应该附上任何其他日志。