1
votes

I have implemented an FTP server based on this here Apache project: http://mina.apache.org/ftpserver-project/index.html

The server is meant to support passive mode and configured accordingly. For testing purposes, I have configured one passive port only (4244), but nothing is listening on this port after starting the server. The FTP server is listening ok on the standard port for active connections and on the one for SSL connections.

When trying to connect with an FTP client, I get the following error (not surprisingly):

Status: Resolving address of localhost

Status: Connecting to [::1]:4244...

Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server", trying next address.

Status: Connecting to [fe80::1%lo0]:4244...

Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server", trying next address.

Status: Connecting to 127.0.0.1:4244...

Status: Connection attempt failed with "ECONNREFUSED - Connection refused by server".

Error: Could not connect to server

My configuration object is implementing this interface from the Apache project: DataConnectionConfiguration

I have put some logging into the class and noticed that the methods for providing passive ports are never called. I would expected one of the methods (such as requestPassivePort() ) to be called, because how else would the FTP Server know what passive port to listen on? Then again, perhaps I have a misunderstanding regarding the workings of passive FTP. Even though there is some documentation in the Apache project, there isn't much about running a server in passive mode.

Perhaps someone has successfully implemented a passive FTP server using this Apache library and could provide me with some help.

Thanks a lot.

Cheers,

Martin

1
Problem seems to be down to the server not being able to establish the data channel in passive mode:2014.01.09-16:17:09.289 INFO : pool-43-thread-8: FtpLoggingFilter: RECEIVED: PASV 2014.01.09-16:17:09.368 WARNING: pool-43-thread-8: PASV: Failed to open passive data connection org.apache.ftpserver.DataConnectionException: Failed to initate passive data connection: Failed to resolve addressmarw

1 Answers

-1
votes

In case someone else has a similar problem: The issue was that several interface methods were not fully implemented. - getExternalAddress() returned a null value and the Apache library didn't deal with it correctly (well, it is supposed to also accept a null value, but didn't) - requestPassivePort() did not return -1 when all passive ports had been used up.

After fully implementing these methods, access in passive mode through a firewall works.