SFTP DownloadFile hangs indefinitely when attempting to download moderate sized files
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Hello,
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
foreach (string file in fileList)
{
string filenameNoPath = file.Substring(file.LastIndexOf('/') + 1);
string destination = outputPath + "\\" + filenameNoPath;
using (Stream fileStream = File.OpenWrite(destination))
{
client.DownloadFile(file, fileStream);
fileStream.Close();
}
}
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with SftpClient.DownloadFile and reproduce the hang using the issue's loop, a file over about 100 KB, and Core SFTP Server (x64) on Windows 10. Check the behavior when the remote host closes the connection and compare it with successful smaller or intermittent downloads. Done means the reported download no longer hangs indefinitely under these conditions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100