I'm modifying some code that was previously working with an FTPS library I wrote myself. I've been asked to start using the Apache Commons Net library (FTPClient and FTPSClient mainly) and I'm running into problems doing a file listing. I've read other questions and it's not the enterLocalPassiveMode problem (Apache Commons Net FTPClient and listFiles()), as I'm using that after connecting, but before logging in. The same code works fine on a test server I set up (also using Apache FTP), but doesn't work on the server I need it for.
I've also tried using the "PBSZ 0" and "PROT P" commands, but they're not implemented on the remote system.
502 PBSZ Command not implemented.
502 PROT Command not implemented.
FTPSClient ftpsclient = new FTPSClient(true); // Implicit SSL
ftpsclient.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out), true));
ftpsclient.connect(HOST_ADDR, HOST_PORT); // Using port 990
FTPFile ftpfiles = ftpsclient.listFiles(); // This is where it breaks
I've tried specifying the directory explicitly and using the default:
FTPFile ftpfiles = ftpsclient.listFiles();
FTPFile ftpfiles = ftpsclient.listFiles(REMOTE_DIR);
... but both give the same result. This is the output of the debugging info:
220 FTPS (Version Thu Dec 10 17:23:00 2015) server ready.
331 Password required for ****.
230 User **** logged in.
200 Type set to I
250 CWD Command successful.
257 "/usr/path/to/outbound/directory" is current directory.
227 Entering Passive Mode (XX,XX,XX,XX,24,140) ***Edit: port 6284
150 Opening data connection for '/bin/ls'.
Then it times out after 30 seconds with this stack trace:
Stack Trace: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
I've checked my firewall settings and that host is allowed to connect via port 990 and 6200-6300.
I've also read FTPClient.listFiles not working and Java application hanging during LIST command to FTP Server (Apache Commons FTPClient) and neither of these have helped with my problem.