[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Error in the Java Standard Library while using Tor sock proxy



I'm using a Java program as a network client on TOR. It uses the standard Java support for SOCKS. I'm currently using the SOCKS4 protocol, but I've gotten the same error while using 4, 4a, and 5. The stack trace looks something like this:

Caused by: java.net.SocketException: Reply from SOCKS server contains wrong code
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:401)


I googled this error message and found someone had put up the source code to the JDK uncompressed and browseable on the web (how useful! Wish Sun would do that themselves and let google at it).

http://www.cs.umb.edu/~bill/java/jdk1.4/src/java/net/SocksSocketImpl.java

You searching on that page you can find where it happens, it's right after it contacts the SOCKS server for the first time and it's reading the response from the server. It's expecting a int that will signify a IPv4 (1) or IPv6 (3) connect request, a DNS lookup request (2), and the TOR socks server seems to be returning something that it's not expecting. (Wouldn't have been nice if that error message told us what it got that it didn't expect?)

Any ideas?

Thanks,

myers