Jump to content

SOLVED HTTP request through SOCKS protocol


Recommended Posts

Posted (edited)

I am trying to use Socks5 proxies to make http post requests. The provider for the proxies has disabled http or something. I get the following error;

Exception in thread "main" java.net.SocketException: SOCKS: Connection not allowed by ruleset


I am using the code

    System.setProperty("java.net.socks.username", user);
    System.setProperty("java.net.socks.password", pass);

    Proxy prox = new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(ip, 8000));
    URL url = new URL("https://www.myip.com");
    URLConnection con = url.openConnection(prox);

    con.setConnectTimeout(10000);
    BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));

    String line;
    while ((line = in.readLine()) != null) {
        System.out.println(line);
    }
    in.close();


How do I tunnel(?) this http request through the proxy?

PS I know this is possible because some extension in firefox allows me to use the proxy too I have also tried this code, but it results in the same error : https://pastebin.com/xt6evbm7

 

Solution: System properties are not used for this, need to use Authentication.java

Edited by Bobbey

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...