Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5025217

J2SE 1.4.x fails to communicate through a SOCKS v5 server

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.0
    • core-libs
    • unknown
    • generic

      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.

            jccollet Jean-Christophe Collet (Inactive)
            tharpin Tom Harpin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: