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;
Exact Error is above
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With