title: Manual FTP with commons.net.ftp
body: <p>I am trying to use apache commons to send manual FTP commands as I have to send non-standard FTP commands to a specific server (that accepts them)</p>
  
  <p>Before I try to send these non-standard commands I want to get FTP working manually with commons.net.ftp. Unfortunately I seem to be missing something.</p>
  
  <p><strong>This works fine</strong> (i.e. it retrieves the list of files)</p>
  
  <pre><code>FTPClient ftp = new FTPClient();
  FTPClientConfig config = new FTPClientConfig();
  ftp.configure(config);
  
  ftp.connect("ftp.mozilla.org");
  ftp.login("anonymous", "");
  
  ftp.enterLocalPassiveMode();
  FTPFile[] fileList = ftp.listFiles("/");
  </code></pre>
  
  <p><strong>This doesn't</strong></p>
  
  <pre><code>FTPClient ftp = new FTPClient();
  FTPClientConfig config = new FTPClientConfig();
  ftp.configure(config);
  
  ftp.connect("ftp.mozilla.org");
  ftp.login("anonymous", "");
  
  ftp.sendCommand("PASV");
  ftp.sendCommand("NLST");
  </code></pre>
  
  <p>I get the appropriate response for <code>ftp.sendCommand("PASV");</code> but it times out on <code>ftp.sendCommand("NLST");</code> finally giving me</p>
  
  <pre><code>425 Failed to establish connection.
  </code></pre>
  
  <p>I have tried to research the topic but most advice on this error is for people setting up servers (and it's usually a firewall problem).</p>
  
  <p>Why does it work when <code>net.ftp</code> does it, but not when I send the commands manually?</p>