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

ScpClient blocked in Download() #1302

Open
vPillariseti opened this issue Jan 31, 2024 · 0 comments
Open

ScpClient blocked in Download() #1302

vPillariseti opened this issue Jan 31, 2024 · 0 comments

Comments

@vPillariseti
Copy link

We are connecting to a proprietor device which is running on Linix to download file(s) over ssh using the ScpClient.
We are currently using SSH.NET-2023.0.1 version.

When we are downloaing huge file and during this time if the proprietor device is switched off, then ScpClient's Download function is blocked. On debugging we could see that the program hangs at the call to Monitor.Wait(_buffer); on line 229 of PipeStream.cs.

I used RemotePathTransformation options None and ShellQuote, but it didn't work.

private void Download(string remoteFilePath, string fileName)
        {
            // Use Scp to download the file
            using (ScpClient scp = new ScpClient(IPAddress, UserName, Password))
            {
                scp.OperationTimeout = TimeSpan.FromMilliseconds(Timeout);
                scp.ErrorOccurred += new EventHandler<Renci.SshNet.Common.ExceptionEventArgs>(OnActionErrorOccurred);
                scp.RemotePathTransformation = RemotePathTransformation.ShellQuote;

                scp.Connect();

                using (Stream dlFile = System.IO.File.OpenWrite(fileName))
                {
                    scp.Download(remoteFilePath, dlFile);
                }

                scp.Disconnect();

            }
        }

Looking for some support.

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

1 participant