-
-
Notifications
You must be signed in to change notification settings - Fork 970
Description
On rare occasions, I see 'The session is not open' in ListDirectoryAsync.
The last time I saw it, it was for a server where multiple instances of sftpClient might get created simultaneously with the same username/password, but working with different folders.
SSH.NET 2025.1.0 .Net 9.
My code looks like this:
try
{
await sftpClient.ConnectAsync(cancellationToken);
await sftpClient.ChangeDirectoryAsync(path, cancellationToken);
var asyncList = sftpClient.ListDirectoryAsync(path, cancellationToken);
}
finally
{
if (sftpClient.IsConnected)
sftpClient.Disconnect();
}
"Type": "System.InvalidOperationException",
"HResult": -2146233079,
"Message": "The session is not open.",
"Source": "Renci.SshNet",
"StackTrace": " at Renci.SshNet.Sftp.SftpSession.SendRequest(SftpRequest request)\r\n at Renci.SshNet.Sftp.SftpSession.GetCanonicalPathAsync(String path, CancellationToken cancellationToken)\r\n at Renci.SshNet.SftpClient.ListDirectoryAsync(String path, CancellationToken cancellationToken)+MoveNext()\r\n at Renci.SshNet.SftpClient.ListDirectoryAsync(String path, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource.GetResult()",
"TargetSite": "Void SendRequest(Renci.SshNet.Sftp.Requests.SftpRequest)"