+1 vote
by (180 points)

FTP GetList() gives error
Error Source 'FOLDER' with
Inner Exception FtpException : Can't open data connection (425).

not secure ftp
for any mode - Passive true/false

Tested on latest libraries
Any ideas?

Thanks

Applies to: Rebex FTP/SSL

1 Answer

0 votes
by (58.9k points)

Hello,

the FTP protocol is quite unique, because it opens a data connection for each transfer / listing, etc. (The port 21/990 is only used for the control connection).

So my guess is that most probably this is some firewall configuration error or some network issue. You need to open a range of ports for the data connection to go through the firewall. The error that you get simply says that the data connection could not be opened.

Passive mode is more firewall friendly, so I'd suggest you to start with Passive mode (default in Rebex FTP) like this:

        Ftp ftp = new Ftp();

        // create a log of communication
        ftp.LogWriter = new Rebex.FileLogWriter("log.txt", Rebex.LogLevel.Debug);


        ftp.Connect("server");
        ftp.Login("user", "password");

        ftp.GetList();

        ftp.Disconnect();

For more information about ports used for control / data connection in FTP see
http://forum.rebex.net/704/ports-used-by-ftp

The exact same error that you get is discussed at
https://forum.filezilla-project.org/viewtopic.php?t=24925

Let me know whether you were able to solve the issue.

by (180 points)
Hi, thank you for response - here 's the log

2015-12-03 09:35:37.718 DEBUG Ftp(24)[5] Info: Accepting data connection.
2015-12-03 09:35:37.721 INFO Ftp(24)[5] Command: PORT 10,10,20,5,167,149
2015-12-03 09:35:37.752 INFO Ftp(24)[5] Response: 200 Port command successful
2015-12-03 09:35:37.752 INFO Ftp(24)[5] Command: MLSD
2015-12-03 09:35:37.783 INFO Ftp(24)[5] Response: 150 Opening data channel for directory list.
2015-12-03 09:35:47.783 INFO Ftp(24)[5] Response: 425 Can't open data connection.
2015-12-03 09:35:47.783 DEBUG Ftp(24)[5] Info: Data connection not accepted.
2015-12-03 09:35:47.786 DEBUG Ftp(24)[5] Info: Error while starting data transfer: Rebex.Net.FtpException: Can't open data connection (425).
   at Rebex.Net.Ftp.SM(String A, Boolean B, VS C, WP D, Int64 I, FtpTransferState J)
2015-12-03 09:35:47.787 DEBUG Ftp(24)[5] Info: Error while initializing data connection.
2015-12-03 09:35:47.787 ERROR Ftp(24)[5] Info: Rebex.Net.FtpException: Can't open data connection (425).
   at Rebex.Net.Ftp.SM(String A, Boolean B, VS C, WP D, Int64 I, FtpTransferState J)
   at Rebex.Net.Ftp.PO(String A, Boolean B, Stream C, Int64 D, String I, WP J)
2015-12-03 09:35:47.787 ERROR Ftp(24)[5] Info: Rebex.Net.FtpException: Can't open data connection (425).

ftp in passive mode
port range 42900 - 42910

ftp runs under azure server - any ideas what can cause this issue?
Thanks!
by (58.9k points)
In your log there is PORT command which means you are attempting active mode, not passive! Please set

    ftp.Passive = true;

As to the port range. 10 ports is definitely not enough for FTP to go through. Open at least 100-200 ports. E.g. try 42800-42999...

Let me know if it helped.

If FTP is too complicated to setup, you could consider using SFTP protocol. Much more firewall friendly and Rebex offers free Tiny SFTP server (https://www.rebex.net/tiny-sftp-server/) to test and Rebex SFTP client library that has the same price as Rebex FTP client
...