sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.88k stars 917 forks source link

SftpClient: handle the SFTP session being closed by the server #1362

Closed mus65 closed 2 months ago

mus65 commented 3 months ago

If the server closes the SFTP session but keeps the TCP connection open, this currently causes IsConnected to return true, but any operation fails with "the session is not open".

SftpClient.IsConnected now also check sftpSession.IsOpen. Connect() and ConnectAsync() were reworked to take into account that the Session may already/still be open, but the SFTP session may not. This is needed so a reconnect works.

fixes #843 fixes #1153 fixes #369

Rob-Hague commented 2 months ago

I tagged @IgorMilavec as co-author for the initial/partial fix.