sshnet / sshnet/SSH.NET

DownloadFile hangs after downloading file

Open
#1,614 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
4.4k
Forks
993
Avg merge
9d 21h
Merged PRs (30d)
1

Description

In the following example, only the "Begin download" console log is written. It successfully downloads the file, but never moves beyond the line with DownloadFile. No errors are thrown, and nothing shows up using the new logging with LogLevel.Trace.

If I add a downloadCallback to DownloadFile, that is called, yet it still never moves forward from that line.

Any ideas what could be happening?

using var sftp = new SftpClient("host", 123, "username", "password"));
sftp.Connect();

using (var fileStream = File.Create(@"C:\target\local\path\file.zip"))
{
    Console.WriteLine("Begin download");
    sftp.DownloadFile("/source/remote/path/file.zip", fileStream);
    Console.WriteLine("End download");
}

Console.WriteLine("Done");

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided C# reproduction and the SftpClient.DownloadFile call, including the optional downloadCallback and LogLevel.Trace behavior described in the issue. Determine why the call does not return after the file downloads; done means the example reaches the “End download” and “Done” console logs without errors.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.