Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Apr 4, 2024

Conversation

mus65
Copy link
Contributor

@mus65 mus65 commented 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.

fixes #843
fixes #1153
fixes #369

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 sshnet#843 and sshnet#1153
src/Renci.SshNet/BaseClient.cs Outdated Show resolved Hide resolved
src/Renci.SshNet/BaseClient.cs Outdated Show resolved Hide resolved
@Rob-Hague
Copy link
Collaborator

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

Copy link
Collaborator

@Rob-Hague Rob-Hague left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@WojciechNagorski WojciechNagorski merged commit 8bd08ed into sshnet:develop Apr 4, 2024
1 check passed
@mus65 mus65 deleted the sftp_fix_isconnected branch September 14, 2024 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants