java - Unable to make a request via proxy -


i want make request via proxy. this, no proxy, works fine:

socket sock = new socket("example.com", 80); outputstream ostream = sock.getoutputstream();  //writing headers send proxy  string request = rtype + " " + uri + " http/1.0"; ostream.write(request.getbytes()); ostream.write(endofline.getbytes());  string cmd = "host: "+ header.get("host"); ostream.write(cmd.getbytes()); ostream.write(endofline.getbytes()); system.out.println(cmd);  //............................ 

but this, proxy, isn't working well, hangs:

proxy prx = new proxy(proxy.type.socks, new inetsocketaddress("my proxy ip address", 1234)); // predefined ip , port sock = new socket(prx); sock.connect(new inetsocketaddress("example.com", 80)); //hangs here ostream = sock.getoutputstream();  //............................ 

what's that?

as @mrsimplemind stated: use proxy.type.http instead of proxy.type.socks.


Comments