我正在将SharpSSH集成到现有的.NET 2.0项目中。所以无法切换到http://sshnet.codeplex.com/或其他较新的库...
我可以通过一个设备连接所有的东西,并且可以运行命令和上传文件而不会出现任何问题。
但是因为这个工具必须能够同时更新多个设备,所以应用程序必须同时启动多个sharpssh连接。然后一切继续工作,但有时一个文件没有完全上传,并抛出错误"session is down“。
SshTransferProtocolBase tx = new Scp(_hostname, _username, _password);
tx.Connect();
tx.OnTransferProgress += new FileTransferEvent(tx_OnTransferProgress);
tx.Put(sshSource.FullName, "/tmp/" + Path.GetFileName(sshTarget));
// --> tx.Put throws the error当像这样用"new Sftp“替换"new Scp”时
SshTransferProtocolBase tx = new Sftp(_hostname, _username, _password);错误消息是:"inputstream is closed“或"session is down”。
对如何避免这种情况有什么想法吗?
非常感谢,弗兰克
发布于 2013-11-22 23:10:16
通过添加具有可定义的最大重试次数的重试循环来解决...
发布于 2012-12-28 15:33:04
我一直在为同样的问题而苦苦挣扎。在多处理过程中出现"session is down“错误是关于SharpSSH的一个已知问题。不再更新此库。所以我建议您使用另一个SSH库,比如SSH.NET:https://github.com/sshnet/SSH.NET
它很容易使用。举个例子:
SshClient sshobject = new SshClient(OSShostIP, OSSusername, OSSpassword);
sshobject.Connect();
sshobject.RunCommand("mkdir /home/nedim");
sshobject.Disconnect();https://stackoverflow.com/questions/13513893
复制相似问题