I was looking for a way to create an embedded ftp server. I came across an example "writing a java ftp server", which I copied and tested locally and everything seemed fine.
So I went on and deployed the example to an AWS EC2 instance and then tried to access it using Ubuntu and FileZilla as clients but I keep getting the same issue where directories do not get listed. I've even tried opening all ports for the instance and I still get the same thing:
I thought it may have something to do with Active/Passive mode settings so I tried with both on FileZilla but I still get the same issue so I'm all out of ideas. Does anyone know how to resolve this?
You have to open the FTP server passive mode data connection port range in the server firewall.
By default the Apache MINA FTP server uses any free unprivileged port for the data connection. To avoid opening all ports for the FTP server, restrict range of ports the server can use. See:
https://mina.apache.org/ftpserver-project/configuration_passive_ports.html
To set the range in code, use the ListenerFactory.setDataConnectionConfiguration
. You can use the DefaultDataConnectionConfiguration
as a implementation of the DataConnectionConfiguration
interface.
See my article on Network configuration for passive mode to understand a background.