sshnet / sshnet/SSH.NET

SSH.NET TimeOut doesn't work above a certain time frame

Offen
#225 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

I am using SSH.NET library to create sftp client. I need to resume the download if network connection becomes available again within this timeout. I am using the below mentioned approach as shown in many examples.

        PrivateKeyFile ObjPrivateKey = new PrivateKeyFile(keyStream);
        PrivateKeyAuthenticationMethod ObjPrivateKeyAutentication = new PrivateKeyAuthenticationMethod(username, ObjPrivateKey);

        var connectionInfo = new ConnectionInfo(hostAddress, port, username, ObjPrivateKeyAutentication);

        try
        {
            using (var client = new SftpClient(connectionInfo))
            {
                client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(10);

                client.Connect();

                if (!client.IsConnected)
                {
                    return false;
                }

                if (!client.Exists(source))
                {
                    return false;
                }

                var fileName = Path.GetFileName(source);

                using (var fs = new FileStream(destination + fileName, FileMode.Create))
                {
                    client.DownloadFile(source, fs, printActionDel);
                    fs.Close();
                    returnState = true;
                }

                client.Disconnect();
                client.Dispose();
            }
        }

I am unplugging the network cable to interrupt the download and test the timeout scenario. Though i enable the internet connection again within the timeout to resume the download, it is not resuming. Am i missing something here.

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

Der Bericht konzentriert sich auf SftpClient, ConnectionInfo.Timeout und DownloadFile. Beginne damit, die Unterbrechung des Netzwerkkabels mit einem 10-Sekunden-Timeout zu reproduzieren, und verfolge, wie die Verbindungswiederherstellung behandelt wird. Suche nach der Implementierung des Timeouts und des SFTP-Downloads sowie den zugehörigen Tests und lege anschließend das erwartete Verhalten fest, wenn die Verbindung vor Ablauf des Timeouts wiederhergestellt 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
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

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