2

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:

FileZilla Output

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?

Community
  • 1
  • 1
Hooli
  • 1,135
  • 3
  • 19
  • 46
  • 1
    Please post the log as text, not as image. This way the messages are not searchable, and other people with the same problem won't be able to find your question. – Martin Prikryl Jul 18 '16 at 14:59

2 Answers2

1

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.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
  • Any ideas on how I can set the default passive port range in the code? – Hooli Jul 18 '16 at 15:34
  • Yeah, I know about that but it requires a thousand input parameters. Pity there's no setter I guess. I'm not sure if this will resolve it since I've already tried with all ports open and it didn't change anything. – Hooli Jul 18 '16 at 16:05
  • It can also be a NAT problem. Read my article carefully. – Martin Prikryl Jul 18 '16 at 16:54
  • And again, please post the log as a text! It's not allowed to post logs/code as an image. See [Discourage screenshots of code and/or errors](http://meta.stackoverflow.com/q/303812/850848). – Martin Prikryl Jul 18 '16 at 17:29
  • Okay, sorry. Too late though, better than nothing. – Hooli Jul 18 '16 at 17:30
  • *"Too late"* is not an excuse. It cannot be that difficult to reproduce the problem again. – Martin Prikryl Jul 18 '16 at 17:32
  • I've been forced to move on and try something else because this wasn't working out so I no longer have this running on the aws instance. I also figured that FTP isn't that great (due to the passive/active thing) and I may as well use SFTP so I'm now stuck with [this question](http://stackoverflow.com/questions/38441969/configure-multiple-user-home-directories) – Hooli Jul 18 '16 at 17:35
1

First, you should try "Passive mode" and "Only use plain FTP (insecure)".

Then, if you are using Windows - try to set "Run the program as an administrator" for the program shortcut or .exe file. It can be done with right click on program shortcut or .exe file. Then "Properties" - "Compatibility" tab.