Java – why does my socks proxy code throw a socketexception: a malformed reply from the SOCKS server?

Why does my socks proxy code throw a socketexception: a malformed reply from the SOCKS server? I tried on urlconnection or other settings, but it didn't work The only useful thing - chilkat lib, but it's commercial So, how can I issue an HTTP request through the asocks proxy? Maybe there are some free LIBS?

For example, the code:

SocketAddress addr = new InetSocketAddress(proxy_ip,proxy_port);
    Proxy proxy = new Proxy(Proxy.Type.soCKS,addr);
    Socket socket = new Socket(proxy);
    InetSocketAddress dest = new InetSocketAddress("google.com",80);
    try {
        socket.connect(dest);
    } catch (IOException ex) {
        Logger.getLogger(CheckProxy.class.getName()).log(Level.SEVERE,null,ex);
    }

Throw exception:

java.net.socketException: Malformed reply from SOCKS server
at java.net.socksSocketImpl.readSocksReply(UnkNown Source)
at java.net.socksSocketImpl.connect(UnkNown Source)
at java.net.socket.connect(UnkNown Source)
at java.net.socket.connect(UnkNown Source)
at proxychecker.CheckProxy.socksCheck(CheckProxy.java:86)

Line 86 is "socket. Connect (dest);"

Solution

SocketException: Malformed reply from SOCKS server
SocketException: Malformed reply from SOCKS server

This indicates that you do not have a socks agent at all Maybe it's an HTTP proxy

Please note that you have raised the wrong question Your code is correct, it's your fault

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>