0 votes
by (150 points)

I am receiving the below error after successfully connecting to an FTP Server from a C# application, but when Listing the items available in the server (using ftp.GetList()), the error appears.

Notes:

  1. When trying to access the server from FileZilla, it only works when
    choosing Encryption: Plain FTP.
  2. I tried to use all types of SSLMode (None, Explicit, Implicit) when
    connecting to the server and non works.
  3. I tried setting IsPassive = true, but also did not work.

The logs including the error:
2024-08-14 10:48:55.952 Opening log file.
*
2024-08-14 10:48:55.952 INFO FileLogWriter(2) [1] Info: Assembly: Rebex.Common 2020 R5 for .NET 4.6-4.8
2024-08-14 10:48:55.952 INFO FileLogWriter (2) [1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-14 10:48:55.952 DEBUG FileLogWriter(2) [1] Info: Culture: en; Windows-1252
2024-08-14 10:48:55.968 DEBUG Ftp (2) [1] Info: Starting data transfer.
2024-08-14 10:48:55.968 VERBOSE Ftp (2) [1] Info: Sent data over control connection:
0000 54-59-50-45-20-41-0D-0A
| TYPE A..
2024-08-14 10:48:55.968 INFO Ftp (2) [1] Command: TYPE A
2024-08-14 10:48:55.968 VERBOSE Ftp (2) [1] Info: Received data over control connection:
0000 |32-30-30-20-54-79-70-65 20-73-65-74-20-74-6F-201 200 Type set to |
0010 41-0D-0A
| A..
2024-08-14 10:48:55.984 INFO Ftp (2) [1] Response: 200 Type set to A
2024-08-14 10:48:56.015 DEBUG Ftp(2) [1] Info: Listening for data connection at 10.20.246.6:49754.
2024-08-14 10:48:56.015 VERBOSE Ftp (2) [1] Info: Sent data over control connection:
0000 | 50-4F-52-54-20-31-30-20 32-30-20-32-34-36-2C-36 PORT 10,20,246,6
0010 2C-31-39-34-20-39-30-0D OA
|,194,90..
2024-08-14 10:48:56.015 INFO Ftp (2) [1] Command: PORT 10,20,246,6,194,90
2024-08-14 10:48:56.015 VERBOSE Ftp (2) [1] Info: Received data over control connection:
0000 |32-30-30-20-50-4F-52-54 20-63-6F-6D-6D-61-6E-64 200 PORT command
0010 20-73-75-63-63-65-73-73 66-75-60-2E-0D-0A
| successful...
2024-08-14 10:48:56.015 INFO Ftp (2) [1] Response: 200 PORT command successful.
2024-08-14 10:48:56.015 VERBOSE Ftp (2) [1] Info: Sent data over control connection:
0000 4D-4C-53-44-20-2A-2E-2A 0D-0A
2024-08-14 10:48:56.015 INFO Ftp (2) [1] Command: MLSD
| MLSD ...
2024-08-14 10:48:56.015 VERBOSE Ftp (2) [1] Info: Received data over control connection:
0000 |35-35-30-20-55-6E-6B-6E 6F-77-6E-20-65-72-72-6F| 550 Unknown erro
0010
72-0D-0A
| r..
2024-08-14 10:48:56.015 INFO Ftp (2) [1] Response: 550 Unknown error
2024-08-14 10:48:56.015 DEBUG Ftp (2) [1] Info: Error while starting data transfer: Rebex.Net. Ftp Exception: Unknown
error (550).
at Rebex.Net.Ftp.quufg(String p0, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
2024-08-14 10:48:56.015 DEBUG Ftp (2) [1] Info: Error while initializing data connection.
2024-08-14 10:48:56.015 ERROR Ftp (2) [1] Info: Rebex.Net. FtpException: Unknown error (550).
at Rebex.Net.Ftp.quufg(String p0, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
at Rebex.Net.Ftp.1rmeg(String po, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)
2024-08-14 10:48:56.015 ERROR Ftp (2) [1] Info: Rebex.Net. FtpException: Unknown error (550).
at Rebex.Net.Ftp.quufg(String po, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
at Rebex.Net.Ftp.1rmeg(String p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)

by (150 points)
No, actually the issue is not being able to retrieve a directory listing from FTP server (using my C# application) using MLSD command with a filter argument, and not in the FileZilla.
From FileZilla there is no ability to apply filtering at the server level, so I have to get all files and then perform filtering at the client side level, but this is not my issue and my question, I justed wanted to compare with it.
The issue is that I want to know why the MLSD with filter argument (when sent from my C# app) is not functioning on this specific server and functions on others?
Especially that the method GetList(string arguments) supports sending filters.
Please note that retrieving all files and then filtering on them is not a good solution since some directories contains large number of files.
Thank you.
by (148k points)
Please note that there are two applications with the "FileZilla" name - the "FileZilla Client" is an FTP client. The "FileZilla Server" is an FTP server, and this seems to be the server you are using from your C# application. See the beginning of the logs you posted earlier today:

2024-08-19 09:59:49.095 DEBUG Ftp (1) [1] Info: Connection succeeded.
2024-08-19 09:59:49.095 INFO Ftp (1) [1] Response: 220-FileZilla Server 1.8.2
2024-08-19 09:59:49.095 INFO Ftp (1) [1] Response: 220 Please visit https://filezilla-project.org/
2024-08-19 09:59:49.111 INFO Ftp (1) [1] Command: USER web_acces
2024-08-19 09:59:49.111 INFO Ftp (1) [1] Response: 331 Please, specify the password.
2024-08-19 09:59:49.111 INFO Ftp(1) [1] Command: PASS *********
2024-08-19 09:59:49.204 INFO Ftp (1) [1] Response: 230 Login successful.

Can you confirm that this instance of "FileZilla Server 1.8.2" is the FTP server from which you are unable to retrieve a directory listing with a filter argument?
by (148k points)
> Especially that the method GetList(string arguments) supports sending filters.

The documentation for this method does not ascribe any meaning to the arguments, does not say that filter arguments are going to work, and it actually explicitly warns against using the arguments at all: https://www.rebex.net/doc/api/Rebex.Net.Ftp.GetList.html

Caution: The meaning of the arguments argument is not defined by RFC and varies from server to server. Some servers interpret it as parameters to dir command, some as a filename, some ignore it and some report an error. Calling this method with arguments other than null is not recommended and will make your code incompatible with many FTP servers.
by (148k points)
A quick survey of some FTP servers in our test lab shows that these servers do not accept MLSD command with filter arguments (which corresponds to RFC 3659):
    FileZilla Server
    Gene6 Server
    GlobalScape EFT
    ProFTPD
    Pure-FTPd

On the other hand, these FTP servers do accept MLSD with filter arguments:
    Titan FTP Server
    vsFTPd
    VanDyke VShell

MS FTP 8 does not support the MLSD command at all. It does support LIST command with filter arguments.

Actually, some of the servers that don't accept MLSD command with filter arguments actually do accept LIST command with filter arguments. To give this a try, you might switch off the MLSD command:

    var ftp = new Ftp();
    ftp.LogWriter = new ConsoleLogWriter(LogLevel.Debug);
    ftp.EnabledExtensions &= ~FtpExtensions.MachineProcessingList;
    ftp.Connect("test.rebex.net");
    ftp.Login("demo", "password");
    ftp.GetList("*.txt");

But, notably, FileZilla Server is not one of these, and will reject LIST command with filter arguments as well.
by (148k points)
Additionally, one clarification: I stated above that MLSD command is not supposed to have any arguments. This is not correct - the MLSD command is allowed to accept a single argument, and that argument must be directory name. Source: https://datatracker.ietf.org/doc/html/rfc3659#section-7.1

However, it's correct that MLSD command's specification explicitly prohibit any filter arguments such as wildcards or question marks. Source: https://datatracker.ietf.org/doc/html/rfc3659#section-2.2.2

1 Answer

0 votes
by (148k points)
selected by
 
Best answer

MLSD command with a filter argument is known to be incompatible with many FTP servers, and is in fact explicitly prohibited by RFC 3659:

For the commands defined in this specification, all pathnames are to be treated literally. That is, for a pathname given as a parameter to a command, the file whose name is identical to the pathname given is implied. No characters from the pathname may be treated as special or "magic", thus no pattern matching (other than for exact equality) between the pathname given and the files present in the NVFS of the server-FTP is permitted.

Even though we are aware of many FTP servers that do support wildcard filter characters in MLSD command arguments (contrary to what the specification says), this behavior cannot be relied upon.

Our documentation for Ftp.GetList(string) cautions against using the arguments:

The meaning of the arguments argument is not defined by RFC and varies from server to server. Some servers interpret it as parameters to dir command, some as a filename, some ignore it and some report an error. Calling this method with arguments other than null is not recommended and will make your code incompatible with many FTP servers.

Notably, "FileZilla Server 1.8.2" (which seems to be the FTP server you are having the issues with, as suggested by your log files) interprets an MLSD argument as a directory path (strictly according to RFC 3659), so filter arguments are not going to work with it.

You can verify that this is indeed the case by checking FileZilla Server's source code (see the engine::async_get_entries method in engine.cpp file and the MLSD command implementation in commander.cpp file).

by (150 points)
Yes, my FileZilla server instance is 1.8.2.
Thank you for your collaboration!
...