Can't connect using FTPS

0 votes
asked Dec 14, 2011 by lance (330 points)
edited Dec 15, 2011

I used the sample code from the tutorial and I can't connect. This is the code I am using:

        Ftp ftp = new Ftp();
        ftp.CommandSent += new FtpCommandSentEventHandler(ftp_CommandSent);
        ftp.ResponseRead += new FtpResponseReadEventHandler(ftp_ResponseRead);

        try
        {
            TlsParameters par = new TlsParameters();
            par.CertificateVerifier = CertificateVerifier.AcceptAll;
            //ftp.Connect(hostname, 21, par, FtpSecurity.Explicit);
            ftp.Connect(hostname, 21, null, FtpSecurity.Explicit);
            ftp.Login(username, password);
            ftp.ChangeDirectory(dirChange);

            long bytes;
            if (method == "get")
            {
                bytes = ftp.GetFile(remoteFile, localFile);
            }
            else if (method == "put")
            {
                bytes = ftp.PutFile(localFile, remoteFile);
            }
            else
            {
                return;
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ftp.Disconnect();
            ftp.Dispose();
        }

The error I get is:

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.

I know this is a timeout error but I'm not sure what else to try.

When I change directories I see username.directory as the current directory. I assume that is correct. The last response I see is "Entering pasive mode".

Applies to: Rebex FTP/SSL
commented Dec 14, 2011 by Lukas Pokorny (107,310 points)
edited Dec 14, 2011

FTP uses a separate TCP connection for each data transfer. According to your description, it looks like it was not possible to establish it. Are you able to connect to the same server from the same client using any third-party FTP client (such as FileZilla) in "explicit TLS/SSL" mode?

commented Dec 14, 2011 by lance (330 points)
edited Dec 14, 2011

Yes I can connect using another client on the same pc.

commented Dec 14, 2011 by Lukas Pokorny (107,310 points)
edited Dec 14, 2011

In that case, would it be possible to create two communication log - one from Rebex FTP/SSL, the other from another client, and mail them to support@rebex.net for analysis? By comparing the two logs, we should be able to tell what to change to make Rebex FTP/SSL work as well. (Use Ftp object's LogWriter property to create a log, as described at http://www.rebex.net/kb/logging.aspx)

commented Dec 14, 2011 by Lukas Pokorny (107,310 points)
edited Dec 14, 2011

Alternatively, try adding this line to your code (right below the Connect method): ftp.Options |= FtpOptions.ConnectPassiveLater; Does this have any effect?

commented Dec 14, 2011 by lance (330 points)
edited Dec 14, 2011

When I make a reference to Rebex.Net i don't see any logging methods.

There is no ConnectPassiveLater value in the FtpOptions enum.

commented Dec 14, 2011 by Lukas Pokorny (107,310 points)
edited Dec 14, 2011

Which version of Rebex FTP/SSL do you use? It looks like it's more than 3 years old. Please try the latest version (3.0.4086.0), let us know whether there is any difference (both with and without the options) and use it to create the log.

commented Dec 14, 2011 by lance (330 points)
edited Dec 14, 2011

Ok I get farther along now and get the error: username.directory.filename not found (550).

I know the file exists since I can see it using the other FTPS client.

Is that path above correct?

If I list the directory using the GetList() method I get the error that no datasets are found.

commented Dec 14, 2011 by lance (330 points)
edited Dec 14, 2011

I sent a log. thanks

commented Dec 14, 2011 by Lukas Pokorny (107,310 points)
edited Dec 14, 2011

Thanks - I replied via e-mail. Looks like you are connecting to a mainframe server. These often have additional requirements, need special "SITE something" commands sent, etc. If you can connect with another client, the easiest solution would be to look into its log as well and compare it with Rebex FTP/SSL log to see what we do differently.

commented Dec 14, 2011 by lance (330 points)
edited Dec 14, 2011

I was able to get this to work. The combination of the new bits and the fact that I was using a directory name without single quotes was the problem. The change directory command was taking me to username.dir instead the the correct directory which is why I was getting the filename not found 550 error.

I have a version question. The new bits I downloaded are breaking my SSH FTP now since it refers to a ProxySocket version problem. Should I start a new thread?

1 Answer

0 votes
answered Dec 14, 2011 by lance (330 points)
edited Dec 15, 2011

I was able to get this to work. The combination of the new bits and the fact that I was using a directory name without single quotes was the problem. The change directory command was taking me to username.dir instead the the correct directory which is why I was getting the filename not found 550 error.

commented Dec 15, 2011 by Lukas Pokorny (107,310 points)
edited Dec 15, 2011

Thanks for letting us know about this, we might find it very useful if someone else runs into the same problem.

...