When SftpClient is disconnected during SftpClient .DownloadFile
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 993
- Avg merge
- 9d 21h
- Merged PRs (30d)
- 1
Description
Hi! together!
I've tried to download some files by SftpClient. Sometimes the program got freeze for some reason.
It's what I've tried to debug to see what was happening.
client.DownloadFile(sFilePath, fileStream, offset =>
{
try
{
if (offset > 4389170) // I assume that the connection is disconnected while the file is being downloaded.
client.Disconnect();
}
catch (Exception ex)
{
}
});
I've tried to make SftpClient disconnected while the file is being downloaded.
It seems I success reproduce the problem that I'm dealing with. (Actually I'm not 100% sure..)
It's doing nothing when It's disconnected. It is maybe because nothing come in on the callback function.
When if it turns out it's a bug, how about add some code inside of SftpClient.InternalDownloadFile while clause
if (IsConnected == false)
throw new SshConnectionException("Connection has been disconnected.");
PS. It's my first time to post Issues on github. If there are some mistakes, please let me know.
UPDATE
I've checked it's stuck in a deadlock in SftpFileReader.Read() function when the connection get disconnected while file is being downloaded. Please someone help me and I want to discuss how to solve this problem with all of you.
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 by reproducing the disconnect during SftpClient.DownloadFile, then inspect SftpClient.InternalDownloadFile and the SftpFileReader.Read() deadlock identified in the issue. Trace what happens when the connection closes while the download callback is active. Done means the download no longer hangs and the disconnected state is handled with observable failure behavior.
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
- Mostly clear
- Newbie friendliness
- 35/100