Programmatically FTP Transfer on Port 21 failes

Keywords: Tomcat - 1&1 - Technical issue - Connectivity (SSH/FTP)
Inside Tomcat I am running a Servlet which handles outgoing FTP transfers to remote servers with port 21 using Apache-Jakartas commons-net.3.6.jar library. The initial FTP account connection failes with the following Exception:
Connection closed without indication.

In the Firewall I opened Port 21

I would like to use the code like it is and dont want to make any effort to change the code, so if somebody can help me with this I would be thankful.

By the way - before I tried without success to get the vsftpd server running for port 21 to do manual FTP transfers with FileZilla as the client.

Hello @f3com

The Tomcat Cloud Images already include an SFTP server running (/usr/lib/openssh/sftp-server) on port 22. You should be able to connect through FileZilla to your VM through SFTP. However, in order to use a FTP server, you need to install it and open the port 21. You can install using the commands below:

sudo apt-get upate && sudo apt-get install -y vsftpd

Once installed, you need to configure the server by editing the configuration file /etc/vsftpd.conf.

Regarding the issue:
Connection closed without indication.

Did the error appeared after trying to fetch a file to your Tomcat server? If so, what directory where you trying to locate the file and what permissions does the directory have?

Best Regards,

Juan Ariza

Thank you for the quick response. Uploading files with FileZilla using the prepared SFTP port 22 isn’t the problem and it works fine.

The problem is the in Java programmed logic of our application running inside the Tomcat. It tries
to open the FTP connection to the remote FTP server on port 21 for uploading files to remote servers. And this failes. The API which is used is from Jakarta commons-net-3.6.jar. From our normal Web-Server this logic is running fine, also manually with FileZilla the connection is no problem. So I assume there is anything in the Bitnami environment which causes the error (Java Ecxeption) I mentioned. In the Firewall I have additionally opened port 21. So the port is open.

I have located the problem. It was my mistake, I am sorry bothering you for this.

The reason was that I have restricted the target FTP server for security reasons the way that I just allowed a certain FTP client IPs - and the Bitnami one I worked with wasn’t added yet.

Hello @f3com

Great!!! We are glad that you were able to fix the issue an do not worry about bothering, I am sure that would help other people to find out the reason why they cannot connect to a FTP server. I proceed to close this ticket as solved. If you have any other questions, please do not hesitate to open a new thread.

Best Regards,

Juan Ariza

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.