You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SFTP DownloadFile hangs indefinitely when attempting to download moderate sized files #733
I've been using SSH.NET for the past month for SFTP downloads and have been encountering an issue that I do not know how to work around. When calling the SftpClient DownloadFile method while attempting to download a file over about 100 KB the program will hang indefinitely even if the connection is forcibly closed by the remote host. This issue occurs inconsistently as sometimes I am able to download files without problem. After testing I have found this issue occurs with both the latest release available through NuGet and the 2020.0.0-beta1 release.
The code I am using to download files is listed below
The platform I am using to test is Core SFTP Server (x64) installed on a Windows 10 Home machine. The connection between the testing platform and the client is my home LAN.
I've looked into PSCP and unfortunately the company I work for does not allow us to use external executables like this, to add functionality to our project it has to be able to be added through NuGet or as a reference. Thank you for taking the time to make this recommendation though I really appreciate it.
Putty is the recommended software for connecting to linux. Since PSCP is part of Putty and its open source, Im surprised your company doesn't allow it.
Ever hear of a work around. Sometimes things don't work and we don't have time to fix someone else's issue. How does your reply help anyone or anything about this issue?
k5123 have you tried to open a new issue? I never got a reply here from one of the SSH.NET developers and I believe I saw a few other issues pointing out similar problems.
k5123 have you tried to open a new issue? I never got a reply here from one of the SSH.NET developers and I believe I saw a few other issues pointing out similar problems.
Yeah probably a good idea. This issue was the one that came up on the search. But lets see if we can get a response with a new one.
Can anyone of you reproduce this issue consistently (and preferrably fast)? Can you reproduce this against a (non-production) server that I can access as well (public or privately)?
Can anyone of you reproduce this issue consistently (and preferrably fast)? Can you reproduce this against a (non-production) server that I can access as well (public or privately)?
I can, need to set up the SFTP endpoint though. Will take me a while. Sorry, my connection here (on vacation) keeps dropping, can't get this set up on short notice. However, any local sftpd + a large file will do.
I have done some testing in the past few days using the latest release available thru NuGet and have been unable to reproduce this issue. Although I am testing with files much smaller then 15gb so the testing I did won't be very useful for k5123's issue. It does seem like the issue I was experiencing with moderately sized files has been fixed in the latest release. If I do run into this issue again I will comment here.
Ok, i've tested things a bit more, and the issue seems to be a combination of two problems, one of which sits in SSH.NET. When comparing plain download performance (SftpClient::DownloadFile()) is dramatically slower when compared to the OpenSSH sftp client in Windows Server or Linux. We're talking 5 mins (openSSH) vs 30 mins (SSH.NET) on the same network link, same file.
The other issue i observed - the intermittent freezes during download - appear to be related to PoSH-SSH, and i'm still looking into that one.
Should i open a separate issue for the download performance?
Update: I changed the capped buffer size from 65k to 256k, and was able to attain similar speeds as the OpenSSH sftp client. Is there a specific reason the size is hard capped to 65k in the current impl?
Activity
zachmakki15 commentedon Oct 14, 2020
After doing more research on this issue I found this link where someone else reports experiencing the same thing with SSH.NET and also shows testing done with other SSH clients https://forum.rebex.net/12973/sftp-file-downloads-hang-for-large-files. In one of the responses in the link someone mentions working around this issue by disables data transfer during SSH negotiation. Is anyone aware of how I might go about doing this?
gavin1970 commentedon Oct 14, 2020
I use PSCP
https://github.com/gavin1970/Linux-Commander/blob/master/Linux-Commander/common/Processor.cs
Line: 171
zachmakki15 commentedon Oct 14, 2020
gavin1970 thank you for commenting, I am not very familiar with PSCP so I will have to look into it.
gavin1970 commentedon Oct 15, 2020
Its part of the putty suite, however the suite isnt required. The developer of putty has it available for download from his website.
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
zachmakki15 commentedon Oct 15, 2020
I've looked into PSCP and unfortunately the company I work for does not allow us to use external executables like this, to add functionality to our project it has to be able to be added through NuGet or as a reference. Thank you for taking the time to make this recommendation though I really appreciate it.
gavin1970 commentedon Oct 15, 2020
Putty is the recommended software for connecting to linux. Since PSCP is part of Putty and its open source, Im surprised your company doesn't allow it.
k5123 commentedon Jul 15, 2021
How is this helping anybody related to this issue, exactly?
k5123 commentedon Jul 15, 2021
Seeing similar behavior when downloading large (15gb) files. Download will hang intermittently for a while, then continue.
gavin1970 commentedon Jul 15, 2021
Ever hear of a work around. Sometimes things don't work and we don't have time to fix someone else's issue. How does your reply help anyone or anything about this issue?
zachmakki15 commentedon Jul 15, 2021
k5123 have you tried to open a new issue? I never got a reply here from one of the SSH.NET developers and I believe I saw a few other issues pointing out similar problems.
k5123 commentedon Jul 15, 2021
Yeah probably a good idea. This issue was the one that came up on the search. But lets see if we can get a response with a new one.
drieseng commentedon Jul 15, 2021
Can anyone of you reproduce this issue consistently (and preferrably fast)? Can you reproduce this against a (non-production) server that I can access as well (public or privately)?
k5123 commentedon Jul 15, 2021
I can, need to set up the SFTP endpoint though. Will take me a while.Sorry, my connection here (on vacation) keeps dropping, can't get this set up on short notice. However, any local sftpd + a large file will do.zachmakki15 commentedon Jul 19, 2021
I have done some testing in the past few days using the latest release available thru NuGet and have been unable to reproduce this issue. Although I am testing with files much smaller then 15gb so the testing I did won't be very useful for k5123's issue. It does seem like the issue I was experiencing with moderately sized files has been fixed in the latest release. If I do run into this issue again I will comment here.
k5123 commentedon Aug 4, 2021
Ok, i've tested things a bit more, and the issue seems to be a combination of two problems, one of which sits in SSH.NET. When comparing plain download performance (SftpClient::DownloadFile()) is dramatically slower when compared to the OpenSSH sftp client in Windows Server or Linux. We're talking 5 mins (openSSH) vs 30 mins (SSH.NET) on the same network link, same file.
The other issue i observed - the intermittent freezes during download - appear to be related to PoSH-SSH, and i'm still looking into that one.
Should i open a separate issue for the download performance?
k5123 commentedon Aug 4, 2021
Update: I changed the capped buffer size from 65k to 256k, and was able to attain similar speeds as the OpenSSH sftp client. Is there a specific reason the size is hard capped to 65k in the current impl?