I still have some problems regarding the FTP session between my simple FTP client written in Java and a proFTP server.
I have connected to the server using passive mode.
When I send the list
command I get a response in ASCII of which files that are on the server. If I send the list
command again, I don´t get any response. I cannot even get a response from other FTP commands that I send. It seems like the session "hangs".
Why does my simple java application stop getting replies when sending the list
command a second time?
In FTP, both active and passive modes supply a separate channel for transferring data. Whenever you want to send a command in passive mode that involves the sending of data (e.g.
list
) you must re-send thePASV
to tell the server that you're about to perform an operation that involves the data connection. The server can then open up a new socket or continue to use the same one.Here's an example session:
Notice that my second attempt to use
LIST
failed because I hadn't opened a data channel. Once I sent anotherPASV
, I was able to useLIST
again.