4

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

Dave
  • 233
  • 2
  • 12
  • What if you go like `client.SslProtocols = SslProtocols.Tls12 |SslProtocols.Tls11 | ...` and add all the protocols. Also, did you specify the port? – Hirasawa Yui Apr 08 '19 at 14:17

1 Answers1

2

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;

Dave
  • 233
  • 2
  • 12