ScpClient blocked in Download()
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
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.
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 PipeStream.cs line 229 and the ScpClient.Download call shown in the report. Reproduce a large-file download while switching off the remote device, then trace how the stream and disconnect are handled after Monitor.Wait(_buffer). Done means the download no longer remains blocked when the SSH peer disappears.
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
- 35/100