Scp transfer is slow
I've been experimenting with the scp implementation and it is slower compared to the command line tool scp. In my test, it is 5s to copy several files with scp, and 33s with SSH.NET. I noticed that most of the time, it was stuck in a Thread.Sleep (100) in ScpClient.ReadByte, so I changed this to Thread.Sleep(0) and it went down to 15s.
I initially reported this on the old codeplex site and as recommended I'm now filling an issue on GitHub.
This is not blocking as I can use sftp instead which is faster.
Thanks!
@manu-silicon I just released version 2016.0.0-beta2 of SSH.NET. Can you confirm SCP performance has improved with that release ? Thanks!
@drieseng Just tried the new version, while it is faster than before (about 7s), it is still slower than the sftp version (2s). Thanks!
@drieseng Thanks for your contribution on this!
I have a concern though. Connection alone to my dev server averages for about 12 seconds. Is there any way to make it faster?
Piece of code below, for your reference:
private void Connect()
{
bool success = true; try { this.client = new SftpClient("xxx.xxx.xxx.xx", "username", "password"); this.client.Connect();//THIS PART TAKES ABOUT 12 SECONDS ON AN AVERAGE } catch (Exception ex) { success = false; ErrorMessage = "SFTP-Connect()|" + ex.Message.ToString(); }
}
I'm currently using Parallelism in my console app (Parallel.Foreach, Task.Factory.StartNew) for faster processing, for it reads several files from an SFTP path. But the connection part kills me.
Appreciate your prompt help, I'm currently applying this on my SFTP-related project.
Cheers,