+1 vote
by (170 points)
edited

I am evaluating Rebex SFTP .Net Framework 4.0 library. In fact was about to recommend it, after trying download, move files etc. Everything seems to be fine until you try to download a file multiple times. First attempt works, second attempt timed out initially, but then i increased the timeout property to 120 secs which kind of resolved it, but it takes so long to download.

I followed the sample code, in this order
Connect
Login
Getfile (remote file, Stream)
Disconnect


So is the SFTP class, locking the file, or connection?


This solution will be used to download many files from an SFTP server, every minute, so can't have it timeout randomly or take a minute to download one file. The file size is just 4 KB.


Regards,
Ali

Applies to: Rebex SFTP
by (58.9k points)
edited

Please create a log of the communication using the LogWriter property as described in this article and either post it here or send it to support@rebex.net for analysis. When we see the log we will be able to help you.

by (170 points)
edited

Thanks for the quick update, log file emailed, awaiting your reply.

by (58.9k points)
edited

Thanks for the log. We are just analyzing it. We'll get back to you as soon as possible.

by (58.9k points)
edited

From the log we can see that you are using more Sftp objects which itself should be fine.

However, to be able to find out what causes the issue you experience could you please run a simple program which would use only one Sftp object, connect to the server and download the one particular file which causes trouble? You can use the following code:

Sftp sftp = new Sftp();
sftp.LogWriter = new FileLogWriter(@"C:\temp\log.txt");
sftp.Connect("server");
sftp.Login(...);
sftp.GetFile("/payload123v6\wrapper3523_ConfirmationOfApplication.xml", @"C:\temp\wrapper3523_ConfirmationOfApplication.xml");
sftp.Dispose();

Please again send us the log created with the code snippet. Thank you for your cooperation!

by (170 points)
edited

This is the code am using, to download 3 files from the server, the first time and second time as you can see from the log file, the download is fast, the 3rd time the batch of 3 files is downloaded the last file in the batch takes just over a minute.

here is the code used everytime a file is downloaded as a stream

by (170 points)
edited

                Sftp sftpServer = new Sftp(); 
                using (sftpServer = new Sftp())
               {
                    // Connect to SFTP server and login ...
                    // Download
                    using (MemoryStream fileStream = new MemoryStream())
                    {
                        sftpServer.GetFile(filename, fileStream);
                        Byte[] fileInByte = fileStream.ToArray();

                       //..do something with content
                    }

                    sftpServer.Disconnect();
                }

1 Answer

+1 vote
by (58.9k points)
edited
 
Best answer

We have looked into the log and it looks like the problem might be solved by disabling the transfer queue. Please try to do it like this and let us know the result:

using (Sftp sftp = new Sftp())
{
    // disable transfer queue
    sftp.Settings.DisableTransferQueue = true;

    // Connect to SFTP server
    // Download
    using (MemoryStream fileStream = new MemoryStream())
    {
        sftp.GetFile(filename, fileStream);
        Byte[] fileInByte = fileStream.ToArray();

        //..do something with content
     }

     sftp.Disconnect();
}

By the way do you know what SFTP server are you actually connecting to? It would be interesting for us to know.

by (170 points)
edited

Thanks Tomas, I'll give that a try now and let yo know. Its Titan Server v8.40 that am using as my SFTP server.

by (170 points)
edited

Fantastic, that solved the problem, many thanks for your prompt replies.

Ali

by (58.9k points)
edited

Great news! I am glad it works now. Thank you also for your quick cooperation.

...