2014-08-27 44 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); 
      } 
     }