sshnet / sshnet/SSH.NET

When SftpClient is disconnected during SftpClient .DownloadFile

Offen
#981 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
C#
Sterne
4.4k
Forks
993
Ø Merge
9 T. 21 Std.
Gemergte PRs (30 T.)
1

Beschreibung

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.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, die Verbindungsunterbrechung während SftpClient.DownloadFile zu reproduzieren, und untersuche anschließend SftpClient.InternalDownloadFile sowie den in der Issue identifizierten Deadlock in SftpFileReader.Read(). Verfolge, was passiert, wenn die Verbindung geschlossen wird, während der Download-Callback aktiv ist. Erledigt ist die Aufgabe, wenn der Download nicht mehr hängen bleibt und der getrennte Zustand mit beobachtbarem Fehlerverhalten behandelt wird.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
csharp
Bereich
networking
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.