sshnet / sshnet/SSH.NET

$exception {"Failure"} Renci.SshNet.Common.SshException I get exception on downloading the files

Open
#945 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Hi team

I'm using the below code for downloading files from the SFTP server.

` DataLakeFileSystemClient fileSystemClient = new DataLakeFileSystemClient(connectionString, "container");

        DataLakeDirectoryClient processDirectory = fileSystemClient.GetDirectoryClient("testProcessDir");


        using (var sftp = new SftpClient(host, username, password))
        {
            sftp.Connect();
            var files = sftp.ListDirectory(remoteDirectory);

            foreach (var file in files)
            {
                string remoteFileName = file.Name;
                if (!file.Name.StartsWith(".") && (DateTime.UtcNow - file.LastWriteTimeUtc).TotalHours < 1)
                {
                    DataLakeFileClient newfile = processDirectory.CreateFile(file.Name);

                    using (Stream stream = newfile.OpenWrite(overwrite: true))
                    {


                        sftp.DownloadFile(remoteDirectory + remoteFileName, stream);
                    }
                }
            }`

After downloading 1 or few files it gives execption as $exception {"Failure"} Renci.SshNet.Common.SshException

at Renci.SshNet.Sftp.SftpFileReader.Read()
at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action1 downloadCallback) at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action1 downloadCallback)
at _111111111111.Program.DownloadAll() in D:\workspace\ExampleProjects\111111111111\111111111111\Program.cs:line 75
at _111111111111.Program.Main(String[] args) in D:\workspace\ExampleProjects\111111111111\111111111111\Program.cs:line 15

Please suggest something with which I could download all the files.

Thanks,
Mukesh

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 stack trace at Renci.SshNet.Sftp.SftpFileReader.Read() and SftpClient.DownloadFile(), then inspect the caller at Program.cs lines 75 and 15. Reproduce the loop against an equivalent SFTP server and determine why downloading multiple files raises SshException("Failure"); done means identifying a reproducible cause or required diagnostic details.

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
Needs clarification
Newbie friendliness
22/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.