Answer the question
In order to leave comments, you need to log in
Why doesn't Java want to work with Socks 4 proxy?
Greetings!
Actually straight to the point. While working on the test program, the following problem arose: Java does not want to work with Socks 4 proxies, not at all. I explain the situation:
There is a code of the form
con = (HttpURLConnection) obj.openConnection(new Proxy(Proxy.Type.SOCKS, new InetSocketAddress("host", *port*));
con.setConnectTimeout(Config.CONNECT_TIMEOUT);
con.setReadTimeout(Config.READ_TIMEOUT);
con.setRequestProperty("User-Agent", Config.USER_AGENT);
con.setDoOutput(false);
con.setDoInput(true);
con.setRequestMethod("GET");
con.connect();
java.net.SocketException: Malformed reply from SOCKS server
System.setProperty("socksProxyVersion", "4");
System.setProperty("socksProxyVersion", "4");
System.setProperty("socksProxyVersion", "5");
System.setProperty("socksProxyVersion", "4");
System.setProperty("socksProxyVersion", "4");
System.setProperty("socksProxyHost", "хост");
System.setProperty("socksProxyPort", "порт");
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Answer the question
In order to leave comments, you need to log in
There is no such problem in JDK11, it works with SOCKS4, but you need to set a system property.
You can also create SocksProxy, the method has become public:
public static SocksProxy create(SocketAddress addr, int version)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question