XaolingBao
XaolingBao

Reputation: 1044

Which ports are used with ApacheCommons FTPClient and enterLocalPassiveMode()?

Essentially I have an issue with my Firewall causing my Application to hang when trying with storing files with FTP.

I found out that it had to do with my Firewall allowing access through the ports.

I set my connection port to 21( which I beileve is also the default), and set

ftp.enterLocalPassiveMode();

I tried to allow access through port 21 on my firewall,but it did not work.

I noticed that if I would try to log

ftp.getPassivePort();

it would be a random port for each item uploaded, usually in the 30k-50k range.

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.

So the only thing I can think of is

  1. 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)**

  2. Find someway to use a single passive port if that is what it's going through (which seems to be the case)

  3. 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?

According to http://wiki.apache.org/commons/Net/FrequentlyAskedQuestions

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?"

So it seems that it's initially in Active mode.

Thanks for any help!

Upvotes: 1

Views: 3321

Answers (0)

Related Questions