nmp*_*mpg 5 java authentication socks
我正在尝试将所有连接设置为通过 Socks 5。我有以下代码:
System.setProperty("socksProxyHost" , "xx.xx.xx.xx");
System.setProperty("socksProxyPort" , "yy") ;
System.setProperty("socksProxyVersion" , "5");
System.setProperty("java.net.socks.username" , "username");
System.setProperty("java.net.socks.password" , "password");
Run Code Online (Sandbox Code Playgroud)
但是,每当我尝试如下连接时,我认为这就足够了:
HttpResponse response = httpclient.execute(httppost);
Run Code Online (Sandbox Code Playgroud)
我得到一个例外:
Jun 14, 2015 11:44:01 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {}->http://www.destination.com: SOCKS : authentication failed
Jun 14, 2015 11:44:01 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: Retrying connect to {}->http://www.www.destination.com
Jun 14, 2015 11:44:03 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {}->http://www.www.destination.com: SOCKS : authentication failed
Jun 14, 2015 11:44:03 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: Retrying connect to {}->http://www.www.destination.com
Jun 14, 2015 11:44:05 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: I/O exception (java.net.SocketException) caught when connecting to {}->http://www.www.destination.com: SOCKS : authentication failed
Jun 14, 2015 11:44:05 AM org.apache.http.impl.client.DefaultHttpClient tryConnect
INFO: Retrying connect to {}->http://www.www.destination.com
Jun 14, 2015 11:44:07 AM totalcontrol.TotalControl main
SEVERE: null
java.net.SocketException: SOCKS : authentication failed
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:474)
at java.net.Socket.connect(Socket.java:589)
at org.apache.http.conn.scheme.PlainSocketFactory.connectSocket(PlainSocketFactory.java:117)
at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:177)
at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:304)
at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:611)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:446)
at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:863)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:106)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:57)
...
Run Code Online (Sandbox Code Playgroud)
相同的代码在没有 Socks 5 配置的情况下也能工作。我确定用户/密码是正确的..
我缺少什么来完成这项工作?