FluentFTP
FluentFTP copied to clipboard
GetListing does not return items but FtpWebRequest works
See #597
FTP OS: Unix?
FTP Server: 211- DS620slim FTP server (Synology?)
Computer OS: Windows 10 Pro 2004
FluentFTP Version: 32.4.3
GetListing does not return items, FileZilla and Chrome do/work.
Code:
Yes, the directory is a complete coincidence 😂, I'm using it in https://github.com/KoalaBear84/OpenDirectoryDownloader/
// myownserver.org is the actual server, not made up
FtpClient ftpClient = new FtpClient("myownserver.org");
ftpClient.Connect();
ftpClient.GetListing("/");
ftpClient.GetListing("/[Weekly Playboy]");
// Tried to encode it myself, but this is not needed, as I tested it myself locally with FileZilla server
ftpClient.GetListing("/%5BWeekly%20Playboy%5D");
Logs :
# Connect()
Status: Connecting to ***:21
Response: 220 DS620slim FTP server ready.
Command: USER ***
Response: 331 Guest login ok, send your email address as password.
Command: PASS ***
Response: 230 Guest login ok, access restrictions apply.
Command: FEAT
Response: 211- Extensions supported:
Response: AUTH TLS
Response: PBSZ
Response: PROT
Response: CCC
Response: SIZE
Response: MDTM
Response: REST STREAM
Response: MFMT
Response: TVFS
Response: MLST
Response: MLSD
Response: UTF8
Response: 211 End.
Status: Text encoding: System.Text.UTF8Encoding+UTF8EncodingSealed
Command: OPTS UTF8 ON
Response: 200 OK, UTF-8 enabled
Command: SYST
Response: 215 UNIX Type: L8
# GetListing("/", Auto)
Command: TYPE I
Response: 200 Type set to I.
# OpenPassiveDataStream(AutoPassive, "MLSD /", 0)
Command: EPSV
Response: 229 Entering Extended Passive Mode (|||55654|)
Status: Connecting to ***:55654
Command: MLSD /
Response: 150 Opening BINARY mode data connection for 'file list'.
+---------------------------------------+
Listing: modify=20200512125001;type=file;unique=2DU13AA4;size=6148;UNIX.mode=0755;UNIX.owner=admin;UNIX.group=users; .DS_Store
Listing: modify=20200423193227;type=file;unique=2DU9BC8;size=704;UNIX.mode=0644;UNIX.owner=admin;UNIX.group=users; ReadMe.txt
Listing: modify=20200423191625;type=dir;unique=2DU13910;size=118;UNIX.mode=0755;UNIX.owner=admin;UNIX.group=users; Synology
Listing: modify=20200714131750;type=dir;unique=2DU13AA0;size=0;UNIX.mode=0777;UNIX.owner=admin;UNIX.group=users; Uploads
Listing: modify=20200204234452;type=dir;unique=2DU109;size=168;UNIX.mode=0755;UNIX.owner=admin;UNIX.group=users; [Weekly Playboy]
-----------------------------------------
Status: Disposing FtpSocketStream...
# CloseDataStream()
Response: 226 Transfer complete.
Status: Disposing FtpSocketStream...
# GetListing("/[Weekly Playboy]", Auto)
Command: TYPE I
Response: 200 Type set to I.
# OpenPassiveDataStream(AutoPassive, "MLSD /[Weekly Playboy]", 0)
Command: EPSV
Response: 229 Entering Extended Passive Mode (|||55991|)
Status: Connecting to ***:55991
Command: MLSD /[Weekly Playboy]
Response: 150 Opening BINARY mode data connection for 'file list'.
+---------------------------------------+
-----------------------------------------
Status: Disposing FtpSocketStream...
# CloseDataStream()
Response: 226 Transfer complete.
Status: Disposing FtpSocketStream...
# GetListing("/%5BWeekly%20Playboy%5D", Auto)
Command: TYPE I
Response: 200 Type set to I.
# OpenPassiveDataStream(AutoPassive, "MLSD /%5BWeekly%20Playboy%5D", 0)
Command: EPSV
Response: 229 Entering Extended Passive Mode (|||56012|)
Status: Connecting to ***:56012
Command: MLSD /%5BWeekly%20Playboy%5D
Response: 550 /%5BWeekly%20Playboy%5D can't be listed
Status: Disposing FtpSocketStream...
# CloseDataStream()
Directory listing DOES work for the Synology directory, but doesn't for [Weekly Playboy]. In FileZilla all directories work.
Could it be anything with the PASV thing?
Here is the FileZilla log:
2020-09-04 08:52:36 8844 1 Status: Resolving address of myownserver.org
2020-09-04 08:52:36 8844 1 Status: Connecting to 81.250.179.2:21...
2020-09-04 08:52:36 8844 1 Status: Connection established, waiting for welcome message...
2020-09-04 08:52:36 8844 1 Response: 220 DS620slim FTP server ready.
2020-09-04 08:52:36 8844 1 Command: AUTH TLS
2020-09-04 08:52:36 8844 1 Response: 504 AUTH: security mechanism 'TLS' not supported(17).
2020-09-04 08:52:36 8844 1 Command: AUTH SSL
2020-09-04 08:52:36 8844 1 Response: 504 AUTH: security mechanism 'SSL' not supported(17).
2020-09-04 08:52:36 8844 1 Status: Insecure server, it does not support FTP over TLS.
2020-09-04 08:52:36 8844 1 Command: USER anonymous
2020-09-04 08:52:36 8844 1 Response: 331 Guest login ok, send your email address as password.
2020-09-04 08:52:36 8844 1 Command: PASS *********************
2020-09-04 08:52:37 8844 1 Response: 230 Guest login ok, access restrictions apply.
2020-09-04 08:52:37 8844 1 Command: SYST
2020-09-04 08:52:37 8844 1 Response: 215 UNIX Type: L8
2020-09-04 08:52:37 8844 1 Command: FEAT
2020-09-04 08:52:37 8844 1 Response: 211- Extensions supported:
2020-09-04 08:52:37 8844 1 Response: AUTH TLS
2020-09-04 08:52:37 8844 1 Response: PBSZ
2020-09-04 08:52:37 8844 1 Response: PROT
2020-09-04 08:52:37 8844 1 Response: CCC
2020-09-04 08:52:37 8844 1 Response: SIZE
2020-09-04 08:52:37 8844 1 Response: MDTM
2020-09-04 08:52:37 8844 1 Response: REST STREAM
2020-09-04 08:52:37 8844 1 Response: MFMT
2020-09-04 08:52:37 8844 1 Response: TVFS
2020-09-04 08:52:37 8844 1 Response: MLST
2020-09-04 08:52:37 8844 1 Response: MLSD
2020-09-04 08:52:37 8844 1 Response: UTF8
2020-09-04 08:52:37 8844 1 Response: 211 End.
2020-09-04 08:52:37 8844 1 Command: OPTS UTF8 ON
2020-09-04 08:52:37 8844 1 Response: 200 OK, UTF-8 enabled
2020-09-04 08:52:37 8844 1 Status: Logged in
2020-09-04 08:52:37 8844 1 Status: Retrieving directory listing...
2020-09-04 08:52:37 8844 1 Command: PWD
2020-09-04 08:52:37 8844 1 Response: 257 "/" is current directory.
2020-09-04 08:52:37 8844 1 Command: TYPE I
2020-09-04 08:52:37 8844 1 Response: 200 Type set to I.
2020-09-04 08:52:37 8844 1 Command: PASV
2020-09-04 08:52:37 8844 1 Response: 227 Entering Passive Mode (81,250,179,2,218,109)
2020-09-04 08:52:37 8844 1 Command: MLSD
2020-09-04 08:52:37 8844 1 Response: 150 Opening BINARY mode data connection for 'file list'.
2020-09-04 08:52:37 8844 1 Response: 226 Transfer complete.
2020-09-04 08:52:37 8844 1 Status: Directory listing of "/" successful
2020-09-04 08:52:51 8844 1 Status: Retrieving directory listing of "/Synology"...
2020-09-04 08:52:51 8844 1 Command: CWD Synology
2020-09-04 08:52:52 8844 1 Response: 250 CWD command successful.
2020-09-04 08:52:52 8844 1 Command: PWD
2020-09-04 08:52:52 8844 1 Response: 257 "/Synology" is current directory.
2020-09-04 08:52:52 8844 1 Command: PASV
2020-09-04 08:52:52 8844 1 Response: 227 Entering Passive Mode (81,250,179,2,217,176)
2020-09-04 08:52:52 8844 1 Command: MLSD
2020-09-04 08:52:52 8844 1 Response: 150 Opening BINARY mode data connection for 'file list'.
2020-09-04 08:52:52 8844 1 Response: 226 Transfer complete.
2020-09-04 08:52:52 8844 1 Status: Directory listing of "/Synology" successful
2020-09-04 08:52:54 8844 1 Status: Retrieving directory listing of "/"...
2020-09-04 08:52:54 8844 1 Command: CDUP
2020-09-04 08:52:54 8844 1 Response: 250 CWD command successful.
2020-09-04 08:52:54 8844 1 Command: PWD
2020-09-04 08:52:54 8844 1 Response: 257 "/" is current directory.
2020-09-04 08:52:54 8844 1 Status: Directory listing of "/" successful
2020-09-04 08:52:55 8844 1 Status: Retrieving directory listing of "/[Weekly Playboy]"...
2020-09-04 08:52:55 8844 1 Command: CWD [Weekly Playboy]
2020-09-04 08:52:55 8844 1 Response: 250 CWD command successful.
2020-09-04 08:52:55 8844 1 Command: PWD
2020-09-04 08:52:55 8844 1 Response: 257 "/[Weekly Playboy]" is current directory.
2020-09-04 08:52:55 8844 1 Command: PASV
2020-09-04 08:52:55 8844 1 Response: 227 Entering Passive Mode (81,250,179,2,217,255)
2020-09-04 08:52:55 8844 1 Command: MLSD
2020-09-04 08:52:55 8844 1 Response: 150 Opening BINARY mode data connection for 'file list'.
2020-09-04 08:52:55 8844 1 Response: 226 Transfer complete.
2020-09-04 08:52:55 8844 1 Status: Directory listing of "/[Weekly Playboy]" successful
I have checked also these, but no results in any:
FtpListItem[] res1 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.ForceList);
FtpListItem[] res2 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.ForceNameList);
FtpListItem[] res3 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.NameList);
FtpListItem[] res4 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.AllFiles);
FtpListItem[] res5 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.IncludeSelfAndParent);
FtpListItem[] res6 = ftpClient.GetListing("/[Weekly Playboy]", FtpListOption.UseStat);
Try calling SetWorkingDirectory with your playboy folder and then call getlisting with "/" and see if it works.
Same thing happened to me. After switching to unencrypted connection, it works.
@foyaxe I've seen by default it's FtpEncryptionMode.None which does not work for me.
Ahh, wanted to create a new issue because I thought this one was closed. Luckily it wasn't.
I came across this again, still same server and went to look further. Added the FluentFTP code as a reference project and tried to step into it.
It might be some connection property.
Checked the default Windows 10 ftp tool, just by doing this it works:
- ftp
- open myownserver.org
- anonymous
- anonymous
- cd "[Weekly Playboy]"
- dir
Also the C# FtpWebRequest works.
Console.WriteLine("Creating FtpClient...");
FtpClient ftpClient = new FtpClient("myownserver.org");
Console.WriteLine("Created FtpClient");
Console.WriteLine("Connecting...");
ftpClient.Connect();
Console.WriteLine("Connected");
FtpListItem[] ftpListItems = ftpClient.GetListing("/[Weekly Playboy]");
Console.WriteLine("FluentFTP Listing 1:");
foreach (FtpListItem ftpListItem in ftpListItems)
{
Console.WriteLine($"{ftpListItem.Name}\t{ftpListItem.Size}");
}
ftpClient.SetWorkingDirectory("/[Weekly Playboy]");
ftpListItems = ftpClient.GetListing();
Console.WriteLine("FluentFTP Listing 2:");
foreach (FtpListItem ftpListItem in ftpListItems)
{
Console.WriteLine($"{ftpListItem.Name}\t{ftpListItem.Size}");
}
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://myownserver.org/[Weekly Playboy]/");
request.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream stream = response.GetResponseStream();
StreamReader streamReader = new StreamReader(stream);
string text = streamReader.ReadToEnd();
Console.WriteLine("FtpWebRequest Listing:");
Console.WriteLine(text);
Also tried a really low level one, but not enough experience with TcpClient and NetworkStream to make it work other than displaying: DS620slim FTP server ready.
What could be the issue? I've tried a lot of options including DataConnectionType, ListingDataType.
Just as @robinrodricks said:
Try calling SetWorkingDirectory with your playboy folder and then call getlisting with "/" and see if it works.
This:
SetWorkingDirectory("/[Weekly Playboy]" and then GetListing("", FtpListOptions.NoPath)
The ("", FtpListOptionsNopath) are important. Don't use just GetListing().
That works.
There have been other issues/reports of square brackets confusing directory list commands on specific servers.
Thank goodness they at least understand the square brackets on the CWD command.
Thanks @FanDjango !
Hopefully I will get the same error in server in the future so I can try the solution. The server went offline in the meantime 😅