2014-08-27 110 views
1

我在与Renci SSH.Net一个奇怪的问题连接异常“客户端未连接”,即使上在产量为true之前检查sftp.IsConnected客户端不能与SSH.Net

文件按预期下载。

堆栈跟踪如下:

at Renci.SshNet.Session.SendMessage(Message message) 
at Renci.SshNet.Session.SendDisconnect(DisconnectReason reasonCode, String message) 
at Renci.SshNet.Session.Disconnect() 
at Renci.SshNet.BaseClient.Disconnect() 
at My.Program.MyMethod() in c:\path\to\my\program.cs:line 42 
+1

我目前的工作是'catch(SshConnectionException ex){}' - 这不是理想的 – 2014-08-27 12:37:28

回答

2

我作为well.Please通过这个https://sshnet.codeplex.com/workitem/1561找出导致同样的问题。这是我目前的工作:

 catch (Exception ex) 
     { 
      if (ex is SshConnectionException || ex is SocketException) 
      { 
       _ifwInstance.Error(string.Format("Ignoring {0} during listing directory", ex.Message)); 
      } 
      else 
      { 
       Debugger.Log(0, null, ex.InnerException.ToString()); 
       throw new Exception("Login to SFT FAILED", ex); 
      } 
     }