流利 FTP 无法连接到 FTP 服务器

Fluent FTP Won't connect to FTP Server

我正在尝试使用 Fluent FTP 连接到 FTP 服务器。 我在使用端口 22 (SFTP) 时使用 Filezilla 没有问题。

但是我无法使用 Fluent FTP 连接到它。

var client = new FtpClient(Constants.FtpHost, Constants.FtpUsername, Constants.FtpPassword)
        {
            // DataConnectionType = FtpDataConnectionType.PASV,
            // EncryptionMode = FtpEncryptionMode.Implicit,
            // SslProtocols = SslProtocols.Tls | SslProtocols.Tls11 | SslProtocols.Tls12 | SslProtocols.Tls13,
            Port = 22
        };
        
Console.WriteLine("Connecting...");        
client.Connect();
Console.WriteLine("Connected");

我收到以下错误:无法从传输连接读取数据:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机未能回应

当我取消注释 DataConnectionType = FtpDataConnectionType.PASV 没有任何变化。 当我取消注释 EncryptionMode = FtpEncryptionMode.Implicit 时,出现以下错误: System.IO.IOException: 无法确定帧大小或收到损坏的帧。

我再次遇到 0 个 FileZilla 或 WinSCP 问题。

如有任何帮助,我们将不胜感激。

来自official GitHub page

SFTP is not supported as it is FTP over SSH, a completely different protocol (use SSH.NET for that)

您正在尝试使用 FTP 库连接到 SFTP 服务器。它们是两个完全不同的协议,尽管实现了相同的目标,但没有任何共同点。为该服务器使用适当的 SFTP 库。

FileZilla 和 WinSCP 都支持 FTP 和 SFTP,这就是您使用它们没有问题的原因。