Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DownloadFile hangs after downloading file #1614

Open
mrlife opened this issue Mar 10, 2025 · 3 comments
Open

DownloadFile hangs after downloading file #1614

mrlife opened this issue Mar 10, 2025 · 3 comments

Comments

@mrlife
Copy link

mrlife commented Mar 10, 2025

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");
@Rob-Hague
Copy link
Collaborator

Hard to say unfortunately. If you use the callback argument does it show anything? e.g.

sftp.DownloadFile("/source/remote/path/file.zip", fileStream, n => Console.WriteLine($"Read {n} bytes"));

Are you able to pause the program with a debugger and see where in the library it is stuck?

@mrlife
Copy link
Author

mrlife commented Mar 17, 2025

@Rob-Hague, thanks for the suggestions. The DownloadFile callback's last printed line has the number of bytes of the file, matching ISftpFile.Length.

Debugging in the library code doesn't seem to be fully supported by my IDE, as breakpoints can be hit, but the code cannot be stepped through. I checked multiple break points in SftpClient.InternalDownloadFile but didn't find where it is getting stuck.

If you have any other suggestions, I will check them out.

@Rob-Hague
Copy link
Collaborator

This is not an ideal suggestion but you could pull the code from this repository and build it in Debug configuration. There is already a console app "AotCompatibilityTestApp" which can be useful for running quick tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants