Jump to content

SOLVED HTTP request through SOCKS protocol


Bobbey

Recommended Posts

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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