SftpClient: slow download
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Hi! Thank you for this project, I appreciate your work.
I have a job in js that downloads some files over sftp every night using ssh2-sftp-client.
I decided to rewrite this job in C# using SSH.NET, but it turned out that the same files are now downloaded up to 15 times slower.
For example, a 25 MB file can be downloaded in 5 seconds using ssh2-sftp-client and in over a minute using SSH.NET.
I tested on ubuntu and arch linux in a simple .net 8 project. SSH.NET version - 2023.0.1.
using var sftpClient = new SftpClient(host, port, userName, password);
await using (var localFileStream = new FileStream("/someFile", FileMode.Create, FileAccess.Write))
{
sftpClient.DownloadFile(file.FullName, localFileStream);
}
In case of reading from a stream it even slower:
await using var remoteStream = await sftpClient.OpenAsync("/someFile", FileMode.Open, FileAccess.Read, CancellationToken.None);
await remoteStream.CopyToAsync(localFileStream);
Do you have any ideas on what I should check or what settings I should play with?
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 the SftpClient.DownloadFile and OpenAsync paths shown in the report, then reproduce the comparison in a simple .NET 8 project using the reported 25 MB file and environments. Compare the transfer behavior and relevant settings with ssh2-sftp-client; done means identifying and addressing the cause of the large download-speed difference.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- networking, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100