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 (148k points)
Are you able to list items at our FTP server at test.rebex.net (username: demo, password: password) with Passive=false?
by (150 points)
My application was functional at many servers before and I was able to list items normally from them.. but I faced this issue recently at a specific server only.
Regarding your question, it is saying 'Invalid path (550).' when trying to list items in Directory:"/"
by (148k points)
Even if your application was functioning before with many servers, something might have changed somewhere. The FTP protocol is notoriously firewall-unfriendly and no longer commonly used, so something seemingly simply such as firewall or router upgrade (at the client or server side) can easily break it without affecting anything else.

However, the "Invalid path (550)" error you got from our server was due to the client sending "MLSD *.*" command, because the MLSD command is not supposed to support wildcards (as specified in https://datatracker.ietf.org/doc/html/rfc3659#section-2.2.2). This also does not correspond to the log you posted above, where plain MLSD command (with no arguments) is used. Can you please try again without the "*.*" argument?

Also, regarding the problem you originally reported - would it be possible to provide a more complete log (at LogLevel.Debug instead of LogLevel.Verbose) showing the whole session? And additionally, please provide a corresponding FileZilla log as well showing a successful listing (can be enabled in Edit->Settings->Logging menu)?
by (150 points)
edited by
When trying to list the items without ".*", it worked with no issue, but when trying with ".dat", it didn't work!
So it appears to not be a firewall or security issue.. but still unexplained especially that I used to use any filter when listing files ("*.*", ".*", ".dat"...) and had no issues before on other servers.
Below are the complete logs of the FileZilla and for my application (using LogLevel.Debug)

**FileZilla log:**

2024-08-15 07:34:27 26904 1 Status: Connecting to 10.20.246.20:21...
2024-08-15 07:34:27 26904 1 Status: Connection established, waiting for welcome message...
2024-08-15 07:34:27 26904 1 Response: 220-FileZilla Server 1.8.2
2024-08-15 07:34:27 26904 1 Response: 220 Please visit https://filezilla-project.org/
2024-08-15 07:34:27 26904 1 Status: Plain FTP is insecure. Please switch to FTP over TLS.
2024-08-15 07:34:27 26904 1 Command: USER web_acces
2024-08-15 07:34:45 26904 1 Response: 331 Please, specify the password.
2024-08-15 07:34:45 26904 1 Command: PASS ********
2024-08-15 07:35:05 26904 1 Error: Connection timed out after 20 seconds of inactivity
2024-08-15 07:35:05 26904 1 Error: Could not connect to server
2024-08-15 07:35:05 26904 1 Status: Waiting to retry...
2024-08-15 07:35:10 26904 1 Status: Connecting to 10.20.246.20:21...
2024-08-15 07:35:10 26904 1 Status: Connection established, waiting for welcome message...
2024-08-15 07:35:10 26904 1 Response: 220-FileZilla Server 1.8.2
2024-08-15 07:35:10 26904 1 Response: 220 Please visit https://filezilla-project.org/
2024-08-15 07:35:10 26904 1 Status: Plain FTP is insecure. Please switch to FTP over TLS.
2024-08-15 07:35:10 26904 1 Command: USER web_acces
2024-08-15 07:35:30 26904 1 Response: 331 Please, specify the password.
2024-08-15 07:35:30 26904 1 Command: PASS ********
2024-08-15 07:35:43 26904 1 Response: 230 Login successful.
2024-08-15 07:35:43 26904 1 Command: SYST
2024-08-15 07:35:43 26904 1 Response: 215 UNIX emulated by FileZilla.
2024-08-15 07:35:43 26904 1 Command: FEAT
2024-08-15 07:35:43 26904 1 Response: 211-Features:
2024-08-15 07:35:43 26904 1 Response: MDTM
-08-15 07:35:43 26904 1 Response: REST STREAM
2024-08-15 07:35:43 26904 1 Response: SIZE
2024-08-15 07:35:43 26904 1 Response: MLST type*; size*; modify*; perm*;
2024-08-15 07:35:43 26904 1 Response: MLSD
2024-08-15 07:35:43 26904 1 Response: AUTH SSL
2024-08-15 07:35:43 26904 1 Response: AUTH TLS
2024-08-15 07:35:43 26904 1 Response: PROT
2024-08-15 07:35:43 26904 1 Response: PBSZ
2024-08-15 07:35:43 26904 1 Response: UTF8
2024-08-15 07:35:43 26904 1 Response: TVFS
2024-08-15 07:35:43 26904 1 Response: EPSV
2024-08-15 07:35:43 26904 1 Response: EPRT
2024-08-15 07:35:43 26904 1 Response: MFMT
2024-08-15 07:35:43 26904 1 Response: 211 End
2024-08-15 07:35:43 26904 1 Status: Logged in
2024-08-15 07:35:43 26904 1 Status: Retrieving directory listing...
2024-08-15 07:35:43 26904 1 Command: PWD
2024-08-15 07:35:43 26904 1 Response: 257 "/" is current directory.
2024-08-15 07:35:43 26904 1 Command: TYPE I
2024-08-15 07:35:43 26904 1 Response: 200 Type set to I
2024-08-15 07:35:43 26904 1 Command: PASV
2024-08-15 07:35:43 26904 1 Response: 227 Entering Passive Mode (10,20,246,20,227,209)
2024-08-15 07:35:43 26904 1 Command: MLSD
2024-08-15 07:35:43 26904 1 Response: 150 About to start data transfer.
2024-08-15 07:35:43 26904 1 Response: 226 Operation successful
2024-08-15 07:35:43 26904 1 Status: Directory listing of "/" successful

**My app log when using ".*" in ftp.GetList():**

2024-08-14 16:18:58.254 Opening log file.
2024-08-14 16:18:58.269 INFO FileLogWriter (1) [1] Info: Assembly: Rebex.Common 2020 R5 for .NET 4.6-4.8
2024-08-14 16:18:58.269 INFO FileLogWriter(1)[1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-14 16:18:58.269 DEBUG FileLogWriter(1) [1] Info: Culture: en; Windows-1252
2024-08-14 16:18:58.285 DEBUG Ftp (1) [1] Info: Starting data transfer.
2024-08-14 16:18:58.285 INFO Ftp (1) [1] Command: TYPE A
2024-08-14 16:18:58.285 INFO Ftp (1) [1] Response: 200 Type set to A
2024-08-14 16:18:58.316 DEBUG Ftp (1) [1] Info: Listening for data connection at 10.20.246.6:54979.
2024-08-14 16:18:58.316 INFO Ftp (1) [1] Command: PORT 10,20,246,6,214,195
2024-08-14 16:18:58.316 INFO Ftp (1) [1] Response: 200 PORT command successful.
2024-08-14 16:18:58.316 INFO Ftp (1) [1] Command: MLSD .*
2024-08-14 16:18:58.316 INFO Ftp (1) [1] Response: 550 Unknown error
2024-08-14 16:18:58.316 DEBUG Ftp(1) [1] Info: Error while starting data transfer: Rebex.Net. FtpException: Unknown error (550).
at Rebex.Net.Ftp.quufg(String po, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
2024-08-14 16:18:58.316 DEBUG Ftp (1) [1] Info: Error while initializing data connection.
2024-08-14 16:18:58.316 ERROR Ftp (1) [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)
2024-08-14 16:18:58.316 ERROR Ftp (1) [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 p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)



**My app log when using ".dat" in ftp.GetList():**

2024-08-14 16:26:34.710 DEBUG Ftp (2) [1] Info: Starting data transfer.
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Command: TYPE A
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Response: 200 Type set to A
2024-08-14 16:26:34.710 DEBUG Ftp (2) [1] Info: Listening for data connection at 10.20.246.6:61838.
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Command: PORT 10,20,246,6,241,142
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Response: 200 PORT command successful.
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Command: MLSD .dat
2024-08-14 16:26:34.710 INFO Ftp (2) [1] Response: 550 Unknown error
2024-08-14 16:26:34.710 DEBUG Ftp(2) [1] Info: Error while starting data transfer: Rebex.Net. FtpException: Unknown error (550).
at Rebex.Net.Ftp.quufg(String p0, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
2024-08-14 16:26:34.710 DEBUG Ftp (2) [1] Info: Error while initializing data connection. 2024-08-14 16:26:34.710 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 p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)
2024-08-14 16:26:34.710 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 p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)
by (148k points)
Unfortunately, these logs are not really equivalent. FileZilla apparently used passive mode (PASV command), while Rebex attempted to use active mode (PORT command). FileZilla issued "MLSD" command with no arguments, while your Rebex-based app issued "MLSD .*" . "MLSD .dat". Additionally, the initial part of the Rebex log showing the connection and authentication is missing.

Please try again with Passive = true, with "MLSD" only, and make sure to assign the LogWriter property before calling the Connect method.

It is quite possible that some FTP servers do accept MLSD command with arguments. However, this is explicitly prohibited by MLSD command's specification, and lot of servers don't actually support it.
by (150 points)
Hello Dear

The conclusion of my investigations is that when adding filter to my app, error is occuring when listing files, but without a filter it lists them normally.
I wanted to try if in FileZilla also an error occurs when adding a filter, but I did not find a way to add server side filters, only found client side filters that do not affect the command sent to the server.
As I mentioned before, I used to list files from different servers normally using filters and never had an issue knowing that the app is used across too many servers. Only on one server this issue is faced.
I dont think it is a security issue since I am being able to list files normally without using a filter.
Please note that TransferType in FileZilla is Type I, and my app is Type A, although I tried to change it in the code to type I(Binary), it is still appearing in logs as Type A,
maybe it is forced to be Type A somewhere in the code...

So can the filter issue be solved in any way?
 
I attached below the full logs of files listing of:
- FileZilla (Passive mode and with no filter)
- My C# app using Rebex (Passive mode with no filter)
- My C# app using Rebex (Passive mode with .txt filter)
I wanted to add the logs of FileZilla with .txt filter, but wasnt able to add server side filters using FileZilla, but only client side ones.. so I didnt add the logs.

**FileZilla logs:**

2024-08-19 10:08:31 38492 2 Status: Selected port usually in use by a different protocol.
2024-08-19 10:08:31 38492 2 Status: Requesting https://update.filezilla-project.org/update.php?cpuid=sse%2Csse2%2Csse3%2Cssse3%2Csse4.1%2Csse4.2%2Cavx%2Caes%2Cpclmulqdq%2Crdrnd
%2C1m&initial=0&osarch=64&osversion=10.0&package=1&platform-x86_64-w64-mingw32&updated=0&version=3.44.2
2024-08-19 10:08:31 38492 2 Status: Resolving address of update.filezilla-project.org
2024-08-19 10:08:31 38492 2 Status: Connecting to 49.12.121.47:443...
2024-08-19 10:08:52 38492 2 Error: Connection timed out after 20 seconds of inactivity
2024-08-19 10:08:52 38492 2 Error: File transfer failed
2024-08-19 10:09:03 38492 1 Status: Connecting to 10.20.246.20:21...
2024-08-19 10:09:03 38492 1 Status: Connection established, waiting for welcome message...
2024-08-19 10:09:03 38492 1 Response: 220-FileZilla Server 1.8.2
2024-08-19 10:09:03 38492 1 Response: 220 Please visit https://filezilla-project.org/
2024-08-19 10:09:03 38492 1 Status: Plain FTP is insecure. Please switch to FTP over TLS.
2024-08-19 10:09:06 38492 1 Command: USER web_acces
2024-08-19 10:09:06 38492 1 Response: 331 Please, specify the password.
2024-08-19 10:09:06 38492 1 Command: PASS ********
2024-08-19 10:09:06 38492 1 Response: 230 Login successful.
2024-08-19 10:09:06 38492 1 Command: SYST
2024-08-19 10:09:06 38492 1 Response: 215 UNIX emulated by FileZilla.
2024-08-19 10:09:06 38492 1 Command: FEAT
2024-08-19 10:09:06 38492 1 Response: 211-Features:
2024-08-19 10:09:06 38492 1 Response: MDTM
2024-08-19 10:09:06 38492 1 Response: REST STREAM
2024-08-19 10:09:06 38492 1 Response: SIZE
2024-08-19 10:09:06 38492 1 Response: MLST type*; size*; modify*; perm*;
2024-08-19 10:09:06 38492 1 Response:MLSD
2024-08-19 10:09:06 38492 1 Response: AUTH SSL
2024-08-19 10:09:06 38492 1 Response: AUTH TLS
2024-08-19 10:09:06 38492 1 Response: PROT
2024-08-19 10:09:06 38492 1 Response: PBSZ
2024-08-19 10:09:06 38492 1 Response: UTF8
2024-08-19 10:09:06 38492 1 Response: TVFS
2024-08-19 10:09:06 38492 1 Response: EPSV
2024-08-19 10:09:06 38492 1 Response: EPRT
2024-08-19 10:09:06 38492 1 Response: MFMT
2024-08-19 10:09:06 38492 1 Response: 211 End
2024-08-19 10:09:06 38492 1 Status: Logged in
2024-08-19 10:09:06 38492 1 Status: Retrieving directory listing of "/checks"...
2024-08-19 10:09:06 38492 1 Command: CWD /checks
2024-08-19 10:09:06 38492 1 Response: 250 CWD command successful
2024-08-19 10:09:06 38492 1 Command: PWD
2024-08-19 10:09:06 38492 1 Response: 257 "/checks" is current directory.
2024-08-19 10:09:06 38492 1 Command: TYPE I
2024-08-19 10:09:06 38492 1 Response: 200 Type set to I
2024-08-19 10:09:06 38492 1 Command: PASV
2024-08-19 10:09:06 38492 1 Response: 227 Entering Passive Mode (10,20,246,20,203,70)
2024-08-19 10:09:06 38492 1 Command: MLSD
2024-08-19 10:09:06 38492 1 Response: 150 About to start data transfer.
2024-08-19 10:09:06 38492 1 Response: 226 Operation successful
2024-08-19 10:09:06 38492 1 Status: Directory listing of "/checks" successful




**My app with no filter logs:**

2024-08-20 09:50:37.455 Opening log file.
2024-08-20 09:50:37.471 INFO FileLogWriter (1) [1] Info: Assembly: Rebex.Common 2020 R5 for .NET 4.6-4.8
2024-08-20 09:50:37.471 INFO FileLogWriter (1) [1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-20 09:50:37.471 DEBUG FileLogWriter (1) [1] Info: Culture: en; Windows-1252
2024-08-20 09:50:37.486 INFO Ftp(1) [1] Info: Connecting to 10.20.246.20:21 using Ftp.
2024-08-20 09:50:37.486 INFO Ftp (1) [1] Info: Assembly: Rebex. Ftp 2020 R5 for .NET 4.6-4.8
2024-08-20 09:50:37.486 INFO Ftp (1) [1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-20 09:50:37.486 DEBUG Ftp (1) [1] Info: Culture: en; Windows-1252
2024-08-20 09:50:37.486 INFO Ftp (1) [1] Info: Using proxy none.
2024-08-20 09:50:37.518 DEBUG Ftp (1) [1] Proxy: Connecting to 10.20.246.20:21 (no proxy).
2024-08-20 09:50:37.518 DEBUG Ftp (1) [1] Proxy: Connection established.
2024-08-20 09:50:37.533 DEBUG Ftp (1) [1] Info: Connection succeeded.
2024-08-20 09:50:37.533 INFO Ftp (1) [1] Response: 220-FileZilla Server 1.8.2
2024-08-20 09:50:37.533 INFO Ftp (1) [1] Response: 220 Please visit https://filezilla-project.org/
2024-08-20 09:50:37.549 INFO Ftp (1) [1] Command: USER web_acces
2024-08-20 09:50:37.549 INFO Ftp (1) [1] Response: 331 Please, specify the password.
2024-08-20 09:50:37.549 INFO Ftp(1) [1] Command: PASS
2024-08-20 09:50:37.642 INFO Ftp (1) [1] Response: 230 Login successful.
2024-08-20 09:50:37.658 INFO Ftp(1) [1] Command: FEAT
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: 211-Features:
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: MDTM
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: REST STREAM
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: SIZE
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: MLST type*;size*; modify*; perm*;
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: MLSD
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: AUTH SSL
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: AUTH TLS
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: PROT
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: PBSZ
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: UTF8
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: TVFS
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: EPSV
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: EPRT
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: MFMT
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: 211 End
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Command: OPTS UTF8 ON
2024-08-20 09:50:37.658 INFO Ftp (1) [1] Response: 202 UTF8 mode is always enabled. No need to send this command
2024-08-20 09:50:37.689 INFO Ftp (1) [1] Command: MLST /checks
2024-08-20 09:50:37.689 INFO Ftp (1) [1] Response: 250-Listing /checks
2024-08-20 09:50:37.689 INFO Ftp (1) [1] Response: type=dir; modify-20230409101635.132; perms=cplemfd; /checks
2024-08-20 09:50:37.689 INFO Ftp(1) [1] Response: 250 End
2024-08-20 09:50:37.705 INFO Ftp (1) [1] Command: CWD /checks
2024-08-20 09:50:37.705 INFO Ftp (1) [1] Response: 250 CWD command successful
2024-08-20 09:50:37.705 DEBUG Ftp (1) [1] Info: Starting data transfer.
2024-08-20 09:50:37.705 INFO Ftp (1) [1] Command: TYPE A
2024-08-20 09:50:37.721 INFO Ftp (1) [1] Response: 200 Type set to A
2024-08-20 09:50:37.721 INFO Ftp (1) [1] Command: PASV
2024-08-20 09:50:37.721 INFO Ftp (1) [1] Response: 227 Entering Passive Mode (10,20,246,20,195,232)
2024-08-20 09:50:37.721 DEBUG Ftp(1) [1] Info: Establishing data connection to 10.20.246.20:50152.
2024-08-20 09:50:37.721 DEBUG Ftp (1) [1] Proxy: Connecting to 10.20.246.20:50152 (no proxy).
2024-08-20 09:50:37.721 DEBUG Ftp (1) [1] Proxy: Connection established.
2024-08-20 09:50:37.721 DEBUG Ftp (1) [1] Info: Established data connection from 10.20.246.6:62085.
2024-08-20 09:50:37.721 INFO Ftp (1) [1] Command: MLSD
2024-08-20 09:50:37.721 INFO Ftp (1) [1] Response: 150 Starting data transfer.
2024-08-20 09:50:37.721 DEBUG Ftp (1) [1] Info: Data transfer started.
2024-08-20 09:50:37.736 INFO Ftp (1) [1] Response: 226 Operation successful
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=7851534; modify=20210218082128.314; perms-awrfd; cdrs23.txt
2024-08-20 09:50:37.736 DEBUG Ftp (1) [1] Info: Item: type-file; size=0; modify=20210301132552.231; perms-awrfd; cdrs24.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=20626; modify-20230409110707.388; perms=awrfd; list.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type=file; size=490211044; modify=20210811113839.867; perms-awrfd; list202107.csv
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type=file; size=1089356; modify=20210817104737.916; perms-awrfd; list20210712.txt
2024-08-20 09:50:37.736 DEBUG Ftp (1) [1] Info: Item: type=file; size=941736; modify-20210817105010.504; perms-awrfd; list20210716.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type-file; size=9970998; modify-20210811104033.740; perms-awrfd; list202108.csv
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=10008; modify=20210811094716.382; perms=awrfd; list20210811.csv
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type-file; size=320038; modify-20210901091312.257; perms-awrfd; list20210901-processed.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=110063622; modify=20210812124504.749; perms-awrfd; listcdr.csv
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type-file; size=917; modify-20220105100259.185; perms-awrfd; Message&ping.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=3250422; modify=20210217105330.650;perms=awrfd; SMS_fileslist.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=698; modify=20210310090835.732; perms-awrfd; trace3.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=1334; modify=20210310091502.383; perms-awrfd; trace3_&_4.txt
2024-08-20 09:50:37.736 DEBUG Ftp (1) [1] Info: Item: type=file; size=6873404; modify-20210308082945.069; perms-awrfd; vm13mo_sms202101.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type=file; size=11279014; modify=20210308083115.711; perms-awrfd; vm13mt_sms202101.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type-file; size=0; modify-20210421102607.468; perms-awrfd; vm13mt_sms202103.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type=file; size=6873404; modify=20210308082818.037; perms=awrfd; vm7mo_sms202101.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1) [1] Info: Item: type-file; size=13170968; modify=20210308082440.877; perms-awrfd; vm7mt_sms202101.txt
2024-08-20 09:50:37.736 DEBUG Ftp (1) [1] Info: Item: type=file; size=4782522; modify=20210308080859.550;perms-awrfd; vm8mo_sms202101.txt
2024-08-20 09:50:37.736 DEBUG Ftp(1)[1] Info: Item: type-file; size=9028412; modify=20210308081104.615; perms-awrfd; vm8mt_sms202101.txt
2024-08-20 09:50:37.752 DEBUG Ftp (1) [1] Info: Data transfer ended. 1655 bytes transferred.
2024-08-20 09:50:37.752 DEBUG Ftp (1) [1] Info: Closing downloading data connection.
2024-08-20 09:50:37.752 DEBUG Ftp(1) [1] Info: Transfer ended successfully.
2024-08-20 09:50:37.752 DEBUG Ftp (1) [1] Info: Data connection closed.
by (150 points)
**My app with .txt filter logs:**


2024-08-19 09:59:49.032 Opening log file.
2024-08-19 09:59:49.032 INFO FileLogWriter(1) [1] Info: Assembly: Rebex.Common 2020 R5 for .NET 4.6-4.8
2024-08-19 09:59:49.032 INFO FileLogWriter (1) [1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-19 09:59:49.032 DEBUG FileLogWriter(1) [1] Info: Culture: en; Windows-1252
2024-08-19 09:59:49.064 INFO Ftp (1) [1] Info: Connecting to 10.20.246.20:21 using Ftp.
2024-08-19 09:59:49.064 INFO Ftp (1) [1] Info: Assembly: Rebex. Ftp 2020 R5 for .NET 4.6-4.8
2024-08-19 09:59:49.064 INFO Ftp(1) [1] Info: Platform: Windows 6.2.9200 32-bit; CLR: 4.0.30319.42000
2024-08-19 09:59:49.064 DEBUG Ftp (1) [1] Info: Culture: en; Windows-1252
2024-08-19 09:59:49.064 INFO Ftp (1) [1] Info: Using proxy none.
2024-08-19 09:59:49.080 DEBUG Ftp (1) [1] Proxy: Connecting to 10.20.246.20:21 (no proxy).
2024-08-19 09:59:49.095 DEBUG Ftp (1) [1] Proxy: Connection established.
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.
2024-08-19 09:59:49.204 INFO Ftp (1) [1] Command: FEAT
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: 211-Features:
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: MDTM
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: REST STREAM
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: SIZE
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: MLST type*;size*; modify*; perm*;
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: MLSD
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: AUTH SSL
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: AUTH TLS
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: PROT
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: PBSZ
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: UTF8
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: TVFS
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: EPSV
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: EPRT
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: MFMT
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: 211 End
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Command: OPTS UTF8 ON
2024-08-19 09:59:49.220 INFO Ftp (1) [1] Response: 202 UTF8 mode is always enabled. No need to send this command
2024-08-19 09:59:49.247 INFO Ftp (1) [1] Command: MLST /checks
2024-08-19 09:59:49.249 INFO Ftp (1) [1] Response: 250-Listing /checks
2024-08-19 09:59:49.249 INFO Ftp (1) [1] Response: type=dir; modify-20230409101635.132; perms=cplemfd; /checks
2024-08-19 09:59:49.249 INFO Ftp(1) [1] Response: 250 End
2024-08-19 09:59:49.254 INFO Ftp (1) [1] Command: CWD /checks
2024-08-19 09:59:49.255 INFO Ftp (1) [1] Response: 250 CWD command successful
2024-08-19 09:59:49.273 DEBUG Ftp (1) [1] Info: Starting data transfer.
2024-08-19 09:59:49.274 INFO Ftp (1) [1] Command: TYPE A
2024-08-19 09:59:49.275 INFO Ftp (1) [1] Response: 200 Type set to A
2024-08-19 09:59:49.279 INFO Ftp(1) [1] Command: PASV
2024-08-19 09:59:49.281 INFO Ftp (1) [1] Response: 227 Entering Passive Mode (10,20,246,20,203,61)
2024-08-19 09:59:49.284 DEBUG Ftp(1) [1] Info: Establishing data connection to 10.20.246.20:52029.
2024-08-19 09:59:49.284 DEBUG Ftp (1) [1] Proxy: Connecting to 10.20.246.20:52029 (no proxy).
2024-08-19 09:59:49.286 DEBUG Ftp (1) [1] Proxy: Connection established.
2024-08-19 09:59:49.286 DEBUG Ftp (1) [1] Info: Established data connection from 10.20.246.6:61851.
2024-08-19 09:59:49.287 INFO Ftp (1) [1] Command: MLSD .txt
2024-08-19 09:59:49.288 INFO Ftp(1) [1] Response: 550 Unknown error
2024-08-19 09:59:49.292 DEBUG Ftp (1) [1] Info: Error while starting data transfer: Rebex.Net. FtpException: Unknown error (550).
2024-08-19 09:59:49.288 INFO Ftp (1) [1] Response: 550 Unknown error
2024-08-19 09:59:49.292 DEBUG Ftp (1) [1] Info: Error while starting data transfer: Rebex.Net. FtpException: Unknown error (550). at Rebex.Net.Ftp.quufg(String p0, Boolean p1, lqiiz p2, kuanm p3, Int64 p4, FtpTransferState p5)
2024-08-19 09:59:49.293 DEBUG Ftp (1) [1] Info: Error while initializing data connection.
2024-08-19 09:59:49.294 ERROR Ftp (1) [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 p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)
2024-08-19 09:59:49.295 ERROR Ftp (1) [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.lrmeg(String p0, Boolean p1, Stream p2, Int64 p3, String p4, kuanm p5)
by (148k points)
Thanks for the logs!
To make sure we understand each other correctly: It looks like the only issue you are dealing with here is actually not being able to retrieve a directory listing from FileZilla Server using MLSD command with a filter argument. Is my understanding correct?
by (148k points)
On a related note, there is bug in FileZilla Server 1.8.2 that causes it to report "550 Unknown error" when there is a problem with the directory being listed. See FileZilla forum for details:
    https://forum.filezilla-project.org/viewtopic.php?t=60538#p191704

This has reportedly been solved, possibly in FileZilla Server 1.9.0-rc1:
    https://filezilla-project.org/download.php?type=server&beta=1

Would it be possible to give FileZilla Server 1.9.0-rc1 a try? It will hopefully provide a meaningful error message instead of unhelpful "unknown error".
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!
...