+3 votes

Hi,

I'm having an issue connecting and working with a FTPS connection

I'm doing the following to connect

using (Ftp client = new Ftp())
{
    client.ServerCertificateValidate += ValidateCertificate;

    client.Mode = FtpMode.Passive;
    client.Connect("someftp");
    client.AuthTLS();

    client.Login(ftpAccount.Username, ftpAccount.Password);

    List<FtpItem> items = client.GetList();
    foreach (FtpItem item in items)
    {
         Console.WriteLine("Name:        {0}", item.Name);
         Console.WriteLine("Size:        {0}", item.Size);
         Console.WriteLine("Modify date: {0}", item.ModifyDate);
         Console.WriteLine("Is folder:   {0}", item.IsFolder);
         Console.WriteLine("Is file:     {0}", item.IsFile);
         Console.WriteLine("Is symlink:  {0}", item.IsSymlink);
         Console.WriteLine();
    }


    // Return folder to change to
    folder = items.Where(x => x.Name == ftpFileSetting.RemotePath)
            .Select(x => x.Name)
            .FirstOrDefault();

    client.ChangeFolder(folder);

    // Get FtpItems
    List<FtpItem> filesToCompare = client.GetList()
         .Where(x => ftpFileSetting.FileIdentifier.Contains(x.Name))
         .ToList();

I can connect to the FTP which has to be connected to in PASSIVE mode. However once i change directoy and attempt to do a file list i receive the following error.

Error Image

Regards
Darren

by (720 points)

1 Answer

+1 vote

First, folder listing opens data connection (in passive mode in your case) and downloads the folder contents. Each listing operation opens separate connection (it's wasteful but this is how FTP protocol works).

As you can see, from the logs, it works in the root folder. This means that everything in terms of connecting and downloading works properly.

It fails however for the balvefa folder, the error you see:

S: 425 Unable to build data connection: Not owner 

is the server generated error.

My guess is that you don't have enough permissions to read the content of the folder.

In my opinion the server should return this error earlier, before the 2nd data connection was established, but it's not that important.

by (301k points)
...