title: Which ports are used with ApacheCommons FTPClient and enterLocalPassiveMode()?
body: <p>Essentially I have an issue with my Firewall causing my Application to hang when trying with storing files with FTP.</p>
  
  <p>I found out that it had to do with my Firewall allowing access through the ports.</p>
  
  <p>I set my connection port to 21( which I beileve is also the default), and set </p>
  
  <pre><code>ftp.enterLocalPassiveMode();
  </code></pre>
  
  <p>I tried to allow access through port 21 on my firewall,but it did not work.</p>
  
  <p>I noticed that if I would try to log</p>
  
  <pre><code>ftp.getPassivePort();
  </code></pre>
  
  <p>it would be a random port for each item uploaded, usually in the 30k-50k range.</p>
  
  <p>My application does allow for "Active" mode, but since this is an application that will be used by many users, it seems "Passive" is more preferred, but users might possibly run into the same error as I am.</p>
  
  <p>So the only thing I can think of is </p>
  
  <ol>
  <li><p>somehow allowing for a range on my firewall**(which I don't see an option for a range, as the other values are all single ports)**</p></li>
  <li><p>Find someway to use a single passive port if that is what it's going through <strong>(which seems to be the case)</strong></p></li>
  <li><p>Don't use Passive Mode.  It seems that Passive is recommended on many posts, but I'm not sure why it's fully needed, and why active wouldn't be preferred?</p></li>
  </ol>
  
  <p>According to <a href="http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions" rel="nofollow">http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions</a></p>
  
  <blockquote>
    <p>You can call FTPClient.enterLocalPassiveMode() to enable passive mode. From then on, FTPClient will take care of issuing a PASV command each time it opens a data connection until you change the data connection mode by calling enterLocalActiveMode() or you close the connection.
    I am curious if anyone has any idea what my best course of action should be?  I'm not sure if this is a programming problem, or more suited for another "Stack Community?"</p>
  </blockquote>
  
  <p>So it seems that it's initially in Active mode.</p>
  
  <p>Thanks for any help!</p>