Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

'The session is not open' in ListDirectoryAsync

未关闭
#1,753 5 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
csharp
领域
networking

调研方向

从 SftpClient.ListDirectoryAsync 开始,通过 SftpSession.GetCanonicalPathAsync 和 SftpSession.SendRequest 跟踪报告的路径。尝试使用相同凭据的多个 SftpClient 实例,在列出不同文件夹时复现该故障,并检查 ConnectAsync、ListDirectoryAsync 和 Disconnect 周围的会话生命周期。只有在理解了罕见的 'The session is not open' 故障,并通过可靠的测试或记录在案的限制加以覆盖后,才算完成。

由索引模型根据 Issue 内容生成。

描述

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)"

主要语言
C#
星标
4.4k
派生
993
平均合并
9 天 21 小时
30 天内合并 PR
1

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

sshnet/SSH.NET 的其他 Issue

查看 sshnet/SSH.NET 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。