c# - SSH.NET "Server string is null or empty"异常

标签 c# .net sftp ssh.net

我使用 SSH.NET(2013.4.7 版本)库将文件上传到 SFTP 服务器。 这是我的一段代码:

using (var client = new SftpClient(host, port, username, password))
{
    client.Connect();
    ...
}

我在 Connect() 方法执行时收到以下错误消息: “System.InvalidOperationException:服务器字符串为 null 或空。”

我在这里找到了关于这个问题的小建议:http://www.ipbalance.com/programming/ms-powershell/1098-powershell-how-to-use-sshnet-library-for-cisco-on-windows-7.html 使用“x.x.x.x”主机格式而不是 x.x.x.x,但这对我没有帮助。

host 变量的值为“153.112.49.198”。 端口 为 22。 当我使用具有相同主机、端口、用户名和密码的 FileZilla 工具时,它工作正常。

堆栈跟踪:

System.InvalidOperationException: Server string is null or empty.
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.Connect()
at [here is my method]

我们将不胜感激。

最佳答案

终于,我解决了这个问题。 默认情况下,SFTP 服务器将“最大连接数”设置为值“1”,因此我无法连接,因为 FileZilla 的连接已经创建。

关于c# - SSH.NET "Server string is null or empty"异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38771732/

相关文章:

eclipse - 用于 eclipse Luna 的 JCraft SFTP

c# - 服务总线触发的 Azure 功能因 System.Threading.Tasks.TaskCanceledException 失败

c# - 这是从 DataContext 更新实体的最佳方式吗?

c# - Windsor Container 什么时候触发临时组件的 IKernel.ComponentDestroyed 事件?

c# - 在 C# 中可视化数据结构,例如树和图

c# - sleep block 程序是否退出?它是如何实现的?

c# - 在innerXML 中获取引号以作为“

c# - 从 List<T> 获取特定类型的对象

java - 通过 Java 的 SFTP 连接要求奇怪的身份验证

java - Apache VFS2 - 无法将文件上传到 SFTP 服务器