Search code examples
c#ftpfluentftp

Fluent FTP Won't connect to FTP Server


I'm trying to connect to an FTP Server using Fluent FTP. I have no issue using Filezilla when I use Port 22 (SFTP).

However I can't connect to it using 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");

I Get the following error: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

When I Uncomment DataConnectionType = FtpDataConnectionType.PASV Nothing changes. When I Uncomment EncryptionMode = FtpEncryptionMode.Implicit I Get the following Error: System.IO.IOException: Cannot determine the frame size or a corrupted frame was received.

Once again I have 0 issues with FileZilla or WinSCP.

Any help would be greatly appreciated.


Solution

  • From the official GitHub page:

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

    You're trying to use an FTP library to connect to an SFTP server. They're two completely different protocols that have nothing in common, despite fulfulling the same goal. Use a proper SFTP library for that server.

    Both FileZilla and WinSCP support both FTP and SFTP, that's why you have no problems with them.