JDK-5025217 : J2SE 1.4.x fails to communicate through a SOCKS v5 server
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: unknown
  • Submitted: 2004-04-01
  • Updated: 2004-05-14
  • Resolved: 2004-05-05
Related Reports
Duplicate :  
Description
Here is our setup:
* We have a SOCKS v5 server running on a UNIX box.  It's iPlanet 3.6.  It
is configured to allow unauthenticated access.
* I am running our app server on my machine, and I am also running
the client on my machine - however, the problem also occurs if I run
the client on another machine.
* Not sure if it is the exact same problem, but I see the same errors
with a very simple client/server.  I got the code off the web, and I'm
attaching the source files:  TriviaClient.java and TriviaServer.java

JDK vs Plug-in:
The problem also occurs when running command-line Java, not just
through the Plug-in.  If I run with JDK 1.3, all packets are tunneled
through the SOCKS server.  If I run with JDK 1.4, the SOCKS server
prints out "bad request from <my machine>" in its logs.

The problem occurs in either of these cases:
*  I start up Java with "-DsocksProxyHost=our.socks.host
-DsocksProxyPort=our.socks.port"
*  In the Java source code, I add the lines:
System.getProperties().put("socksProxyHost", "our.socks.host");
System.getProperties().put("socksProxyPort", "our.socks.port");

I read somewhere that I should use System.setProperty() instead of
System.getProperties().put, but that makes no difference.

Looking at the JDK source code
In JDK 1.3, only SOCKS v4 was supported with
java.net.PlainSocketImpl.  SOCKS v5 is supported in 1.4 with
java.net.SocksSocketImpl.  When running TriviaClient, the error
occurs when the Socket class is initialized and tries to connect to the
SOCKS server via java.net.SocksSocketImpl.

In the "connect" method of SocksSocketImpl, the client sends a
NO_AUTH request to the SOCKS server, and that succeeds.  I see the
successful request in the SOCKS server logs as well.  However, the
next part of the code where the client sends the CONNECT request, it
errors out with "SOCKS: Command not supported" SocketException. 
This is when the SOCKS server logs the "bad request" error.

Another strange issue
When I run the 1.4.1 plug-in, the client does not attempt to connect
to the SOCKS server at all - nothing is printed in the SOCKS server log
files.  However, if I run with 1.4.2 plug-in, the client attempts the
connection and the SOCKS server prints out "bad request."  This
discrepency between 1.4.1 and 1.4.2 does not occur if I run from the
command-line.

Please let me know if there is any other information I can provide. 
I've posted messages on the Java forums (with Duke dollars!), but I
haven't gotten any solution.
###@###.### 2004-05-04
The customer was provided with an updated java/net/SocksSocketImpl.class
with the SOCKS5 fix that will appear in j2se 1.5.0 beta 2
This fix has completely resolved the customer's problem!
They urgently need this fix back-ported to j2se 1.4, which is the
reason for Escalation 551817.

Comments
EVALUATION This looks like the same issue as in i.e. iPlanet proxy (which, I believe is the previous name of SunOne proxy) can't deal with fragmented packets even though the SOCKS protocol is TCP based. This has been fixed in 1.5. ###@###.### 2004-04-02 Customer confirmed that this is the same issue as 5019401. Closing as duplicate. ###@###.### 2004-05-05
02-04-2004