1

I am trying to run a simple Java FTP Client (org.apache.commons.net.ftp.FTPClient) program with Docker containerization to obtain some file from a remote FTP server.

Running the app locally (without docker) works fine. The containerized app however does not return any data. Example program:

ftpClient.connect(host, port);
ftpClient.login(usr, pwd);
System.out.println(ftpClient.getReplyString());
filenameList = ftpClient.listNames();
System.out.println(ftpClient.getReplyString());

With Docker, I get the following error message: Connection closed without indication.

Interesting however is that I also receive: 230 User logged in. Any hints?

Nikolai
  • 49
  • 10
  • 1
    Is the other FTP server in the same network as your computer? If yes, the FTP library uses ftp port commands, and those don't work properly is docker – Ferrybig Jun 05 '19 at 16:37
  • No its not, it is in an external Network. – Nikolai Jun 05 '19 at 17:47
  • 3
    Make sure to use ftp passive mode. This will make the ftp server tell your ftp client the connection details for the (next) data connection. – Metin Jun 05 '19 at 19:36
  • @user3460948: Thank you very much, it worked; adding the line `ftpClient.enterLocalPassiveMode();` made the difference! – Nikolai Jun 06 '19 at 06:06

0 Answers0