Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FluentFtp unable to connect but can in filezilla

Tags:

c#

fluentftp

I am using Fluent Ftp to send a file to the server I am connecting fine using quick connect in filezilla but in my code am getting a time out error.

public bool SendFileToFtp(List<FtpFiles> _files)
{
    //create an FTP client
    string ftpHost = Properties.Settings.Default.ftpHost;
    string ftpUserName = Properties.Settings.Default.ftpUser;
    string ftpPassword = Properties.Settings.Default.ftpPassword;
    FtpClient client = new FtpClient(ftpHost);               
    client.Credentials = new NetworkCredential(ftpUserName, ftpPassword);
    client.Connect();
    client.SetWorkingDirectory("/in/input");
    foreach (FtpFiles file in _files)
    {
          client.UploadFile(file.FileName, Path.GetFileName(file.FileName));
    }    
} 

I added the following based of another so but it did not work and not allow me to connect to the end user ftp but can through filezilla.

client.EncryptionMode = FtpEncryptionMode.Implicit;

client.SslProtocols = SslProtocols.Tls12;

enter image description here

Exact Error is above

like image 286
Dave Avatar asked Oct 11 '25 19:10

Dave


1 Answers

Hi All that it appeared to be was good old passive mode had to be set on the client side so adjusting the code to as per this comment on down the link

https://github.com/robinrodricks/FluentFTP/issues/187

artiomchi commented on 16 Sep 2017 I've had some issues with a couple of servers that I was connecting... I believe those servers are at fault, but for all, I know it could be an issue with FluentFTP.

The issue in my case was that FluentFTP will by default attempt to establish an EPSV connection, and will fall back to regular PASV if the server doesn't support it. The server in question reported that it supported EPSV, but connections to it timed out. Forcing a PASV connection solved it for us

client.DataConnectionType = FtpDataConnectionType.PASV;

like image 131
Dave Avatar answered Oct 14 '25 09:10

Dave