Uploaded image for project: 'Commons Net'
  1. Commons Net
  2. NET-637

FTPSClient not using the Socks Proxy when opening passive data connection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 3.5, 3.6
    • None
    • FTP
    • None
    • Windows

    Description

      I'm routing FTPS traffic through a SOCKS proxy host. I setup the proxy using:

      FTPSClient ftps = new FTPSClient("TLS", false);
      InetSocketAddress sa = new InetSocketAddress(proxyHost,proxyPort);
      Proxy proxy = new Proxy(Proxy.Type.SOCKS, sa);
      System.out.println("Using Proxy Server: " + proxy);
      ftps.setProxy(proxy);
      ...
      ftps.enterLocalPassiveMode();
      for (FTPFile f : ftps.listFiles()) {
      System.out.println(f.getRawListing());
      }

      When establishing the connection, the above code does go through the proxy and I'm able to login. When I try to do anything, say listFiles, It does the SYST and then attempts to enter passive mode, but the connection times out:
      227 Entering Passive Mode (123,45,678,9,11,243)
      java.net.ConnectException: Connection timed out: connect
      at java.net.DualStackPlainSocketImpl.connect0(Native Method)
      at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
      at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
      at java.net.PlainSocketImpl.connect(Unknown Source)
      at java.net.SocksSocketImpl.connect(Unknown Source)
      at java.net.Socket.connect(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.connect(Unknown Source)
      at org.apache.commons.net.ftp.FTPClient.openDataConnection(FTPClient.java:920)
      at org.apache.commons.net.ftp.FTPSClient.openDataConnection(FTPSClient.java:627)
      at org.apache.commons.net.ftp.FTPClient.openDataConnection(FTPClient.java:785)
      at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3409)
      at org.apache.commons.net.ftp.FTPClient.initiateListParsing(FTPClient.java:3339)
      at org.apache.commons.net.ftp.FTPClient.listFiles(FTPClient.java:3016)
      at gov.nyc.ftputils.FTPConnection.listFiles(FTPConnection.java:1270)
      at gov.nyc.ftputils.FTPClientUtil.main(FTPClientUtil.java:572)

      I then comment out the proxy code and added:

      System.getProperties().put( "socksProxyPort", proxyPort);
      System.getProperties().put( "socksProxyHost" ,proxyHost);

      And then I'm able to get the listing, get files, etc.

      Adding -DsocksProxyHost=myproxy.host to the java command line also works.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              segantim Michael Seganti
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated: