C# FluentFtp使用tls连接到FTPserver,可以获取工作目录,但尝试获取文件列表时超时

C# FluentFtp使用tls连接到FTPserver,可以获取工作目录,但尝试获取文件列表时超时,c#,connect,fluentftp,C#,Connect,Fluentftp,我有一小段c#测试代码(4.7.2),使用FluentFtp连接到Linux上未知类型和未知Linux派生版本的基于Linux的服务器 我正在开发VS2017 我使用NuGet加载FluentFTP 我的测试代码的.Net级别是4.7.2 到目前为止: 它连接 我可以得到一个工作目录(GetWorkingDirectory()) 当我尝试获取文件列表时,FluentFtp GetListing上会显示“尝试连接时超时!” 代码是: using System; us

我有一小段c#测试代码(4.7.2),使用FluentFtp连接到Linux上未知类型和未知Linux派生版本的基于Linux的服务器

我正在开发VS2017

我使用NuGet加载FluentFTP

我的测试代码的.Net级别是4.7.2

到目前为止:

它连接

我可以得到一个工作目录(GetWorkingDirectory())

当我尝试获取文件列表时,FluentFtp GetListing上会显示“尝试连接时超时!”

代码是:

        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Text;
        using System.Threading.Tasks;
        using System.Net;
        using System.Security.Authentication;
        using System.Diagnostics;

        using FluentFTP;

        namespace TryFLuentFTP {
        class Program {
        static void Main(string[] args) {

            FtpTrace.AddListener(new ConsoleTraceListener());

            FtpTrace.LogUserName = false;   // hide FTP user names
            FtpTrace.LogPassword = false;   // hide FTP passwords
            FtpTrace.LogIP = false;     // hide FTP server IP addresses

            try {
                FtpClient client = new FtpClient("ftp-host", "user", "******"); 
                client.EncryptionMode = FtpEncryptionMode.Explicit;
                client.SslProtocols = SslProtocols.Tls12;

                client.DataConnectionType = FtpDataConnectionType.EPSV;                            //PASV;

                client.DownloadDataType = FtpDataType.Binary;

                client.ValidateCertificate += (c, e) => { e.Accept = true; };
                client.Connect();

                Console.WriteLine("Connected!!!!");

                Console.WriteLine("The working directory is: " + client.GetWorkingDirectory());

                FtpListItem[] list = client.GetListing(client.GetWorkingDirectory());
                // FtpListOption.Modify | FtpListOption.Size);

                foreach(FtpListItem li in list) {
                    Console.WriteLine(li.Type + " " + li.FullName);
                }

            } catch (Exception ex) {
                Console.WriteLine(ex.Message + "\n" + ex.StackTrace);
            }

            Console.ReadLine();
        }
    }
}
控制台输出为:

# Connect()
Status:   Connecting to ***:21
Response: 220 (vsFTPd 3.0.2)
Status:   Detected FTP server: VsFTPd
Command:  AUTH TLS
Response: 234 Proceed with negotiation.
Status:   FTPS Authentication Successful
Status:   Time to activate encryption: 0h 0m 0s.  Total Seconds: 0.106716.
Command:  USER ***
Response: 331 Please specify the password.
Command:  PASS ***
Response: 230 Login successful.
Command:  PBSZ 0
Response: 200 PBSZ set to 0.
Command:  PROT P
Response: 200 PROT now Private.
Command:  FEAT
Response: 211 End
Response: 211-Features:
Response: AUTH TLS
Response: EPRT
Response: EPSV
Response: MDTM
Response: PASV
Response: PBSZ
Response: PROT
Response: REST STREAM
Response: SIZE
Response: TVFS
Response: UTF8
Status:   Text encoding: System.Text.UTF8Encoding
Command:  OPTS UTF8 ON
Response: 200 Always in UTF8 mode.
Command:  SYST
Response: 215 UNIX Type: L8
Status:   Auto-detected UNIX listing parser
Connected!!!!

# GetWorkingDirectory()
Command:  PWD
Response: 257 "/"
The working directory is: /

# GetWorkingDirectory()
Command:  PWD
Response: 257 "/"

# GetListing("/", Auto)
Command:  TYPE I
Response: 200 Switching to Binary mode.

# OpenPassiveDataStream(EPSV, "LIST /", 0)
Command:  EPSV
Response: 229 Entering Extended Passive Mode (|||30454|).
Status:   Connecting to ***:30454
Status:   Disposing FtpSocketStream...
Timed out trying to connect!
   at FluentFTP.FtpSocketStream.Connect(String host, Int32 port, FtpIpVersion ipVersions)
   at FluentFTP.FtpClient.Connect(FtpSocketStream stream, String host, Int32 port, FtpIpVersion ipVersions)
   at FluentFTP.FtpClient.OpenPassiveDataStream(FtpDataConnectionType type, String command, Int64 restart)
   at FluentFTP.FtpClient.OpenDataStream(String command, Int64 restart)
   at FluentFTP.FtpClient.GetListing(String path, FtpListOption options)
   at FluentFTP.FtpClient.GetListing(String path)
   at TryFLuentFTP.Program.Main(String[] args) in C:\DiabesityInstituteProjects\Solutions\DiabesityLabResultProcessing\TryFLuentFTP\Program.cs:line 38
我看过很多SO帖子和FluentFTP问题,并尝试了一些想法。我还尝试了PASV和EPSV,结果相同

由于所有这些带有“tls”的FTP都有点混乱,如果有其他选择,直接.Net或第三方,我当然会考虑他们。我的时间有点紧

问候,,
吉姆

你在这件事上有进展吗?你在这件事上有进展吗?