GetFile with a stream very slow after multiple attempts

+1 vote
asked Dec 19, 2013 by Ali (170 points)
edited Dec 23, 2013

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
commented Dec 19, 2013 by Tomas Knopp (58,890 points)
edited Dec 19, 2013

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.

commented Dec 19, 2013 by Ali (170 points)
edited Dec 19, 2013

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

commented Dec 19, 2013 by Tomas Knopp (58,890 points)
edited Dec 19, 2013

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

commented Dec 19, 2013 by Tomas Knopp (58,890 points)
edited Dec 19, 2013

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!

commented Dec 19, 2013 by Ali (170 points)
edited Dec 19, 2013

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

commented Dec 19, 2013 by Ali (170 points)
edited Dec 19, 2013

                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
answered Dec 19, 2013 by Tomas Knopp (58,890 points)
edited Dec 23, 2013
 
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.

commented Dec 19, 2013 by Ali (170 points)
edited Dec 19, 2013

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.

commented Dec 19, 2013 by Ali (170 points)
edited Dec 19, 2013

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

Ali

commented Dec 19, 2013 by Tomas Knopp (58,890 points)
edited Dec 19, 2013

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

...