5 socks with authentication JVM configuration

I am trying to establish all my connections to get through Socks 5. I have the following code:

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"); 

      

I thought this would be enough, however, whenever I try to connect like this:

HttpResponse response = httpclient.execute(httppost);

      

I am getting an exception:

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

      

The same code works without a Socks 5 configuration. I'm sure the user / password is correct.

What am I missing to make this work?

+3


source to share





All Articles