0

I'm looking to have my application connect to the internet through a proxy server (in order to avoid captcha). The code I am currently using is this:

Properties props = System.getProperties();
props.put("http.proxyPort", proxyPort); //proxy port
props.put("http.proxyHost", proxyHost); //proxy host
props.put("http.proxySet", "true");

This code has been unsuccesful, however. Any suggestions?

7
  • 4
    you are trying to use a proxy not implement one right? Commented Jul 26, 2012 at 14:25
  • 5
    How can you use a proxy to avoid captcha? Commented Jul 26, 2012 at 14:27
  • You might need to set the proxy for https as well. Set the properties https.proxyPort and https.proxyHost. It might also help to set these properties in the JAVA_OPTS environment variable so they're picked up by every Java app on your system. Commented Jul 26, 2012 at 14:27
  • Sites like omegle.com (something my app connects to) generate a captcha depending on how many connections your IP has had in the past minute/hour/day. New IP = avoid captcha. Commented Jul 26, 2012 at 14:33
  • @JohnSmith: That looks like pretty badass idea, that is going to fail, because the proxy doesn't change IP when you connect to it. Or you should use each time another proxy, which is pretty hard. Commented Jul 26, 2012 at 14:34

3 Answers 3

2

You can try the following:

SocketAddress sa = new InetSocketAddress(proxy_host_name, proxy_port_address);
Proxy proxy = new Proxy(Proxy.Type.xxx, sa);
URLConnection con = new URL(url).openConnection(proxy);
Sign up to request clarification or add additional context in comments.

Comments

0

You are probably using a kind of "User Friendly Website Proxy", like http://newipnow.com or www.proxyultra.com. But you need to use a real SOCKS proxy server.

A free server, that I found, working, in a list of public Proxies:

System.setProperty("http.proxyHost", "187.115.172.82");
System.setProperty("http.proxyPort", "8181");

There is no need to set the http.proxySet property.

Pick a server from the nice list here: Hide My Ass: Proxy List

Comments

0

Put the parameters on the command line or use setProperty.

java -Dhttp.proxyHost=proxy.host -Dhttp.proxyPort=3128 MainClass

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.