Socks 5 with authentication JVM config

1k views Asked by At

I am trying to set all my connections to go through a 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 that this would be enough, however, whenever I attempt a connection as follows:

HttpResponse response = httpclient.execute(httppost);

I get 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 the Socks 5 configuration. I'm sure the user/password are correct..

What am I missing to make this work?

0

There are 0 answers