You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a connection pool implemented for the SftpClient and we reconnect whenever SftpClient.IsConnected() returns false.
However we have noticed issues where SftpClient.IsConnected() still returns true in case the server has closed the session and we eventually get the following error when using the client for any operation
System.InvalidOperationException: The session is not open. at Renci.SshNet.Common.AsyncResult.EndInvoke() at Renci.SshNet.SftpClient.EndListDirectory(IAsyncResult asyncResult)
Is this an expected behaviour? If not, can we try to implement the fix mentioned #843 or expose a method to determine if the session is open or not?
The text was updated successfully, but these errors were encountered:
mus65
added a commit
to mus65/SSH.NET
that referenced
this issue
Mar 23, 2024
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.
fixessshnet#843 and sshnet#1153
* SftpClient: handle the SFTP session being closed by the server
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 and #1153
* Always re-create session
---------
Co-authored-by: Rob Hague <[email protected]>
Co-authored-by: Igor Milavec <[email protected]>
This is similar to the discussion in #843
We have a connection pool implemented for the SftpClient and we reconnect whenever SftpClient.IsConnected() returns false.
However we have noticed issues where SftpClient.IsConnected() still returns true in case the server has closed the session and we eventually get the following error when using the client for any operation
Is this an expected behaviour? If not, can we try to implement the fix mentioned #843 or expose a method to determine if the session is open or not?
The text was updated successfully, but these errors were encountered: