a error in version 10805

Oct 27, 2011 at 3:57 PM

I referenced to 9380 change set In my project

but found an exception occured at sftp.dispose() sometimes

so I wan't change my project to the newest version 10805

but found i can't send any sshcommand success.

my code is similar to below

using (var client = new SshClient("", "rootname", "rootpassword"))
    var result = ExecuteTestCommand(client);


private static bool ExecuteTestCommand(SshClient s)
   var testValue = Guid.NewGuid().ToString();
   var command = string.Format("echo {0}", testValue);
   var cmd = s.CreateCommand(command);
   var result = cmd.Execute(); // exception occur at here
   result = result.Substring(0, result.Length - 1);

   return result.Equals(testValue);

i go into the SshCommand.Excute(), finally find exception throwed at Session.WaitHandle(WaitHandle waitHandle)

after excute var index = EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout);

index's value is 0


is there anthing wrong with the code or my call method is incorrect?

can anybody help me?


Oct 27, 2011 at 4:17 PM



I could take a look at it only in couple weeks, unfortunately.

Meanwhile, can you post more specific exception that you get? I f possible of course.




Oct 28, 2011 at 12:15 AM

An established connection was aborted by the software in your host machine.

Oct 28, 2011 at 12:16 AM

Renci.SshNet.Session.SocketRead(Int32 length, Byte[]& buffer)  E:\WorkSpace\Renci.SshClient\Renci.SshNet\Session.NET.cs:line 69
Renci.SshNet.Session.Read(Int32 length)  E:\WorkSpace\Renci.SshClient\Renci.SshNet\Session.cs:line 1416
Renci.SshNet.Session.ReceiveMessage()  E:\WorkSpace\Renci.SshClient\Renci.SshNet\Session.cs:line 731
Renci.SshNet.Session.MessageListener()  E:\WorkSpace\Renci.SshClient\Renci.SshNet\Session.cs:line 1492

Oct 28, 2011 at 1:48 AM

System.Net.Sockets.SocketException (0x80004005): 

   Renci.SshNet.Session.WaitHandle(WaitHandle waitHandle) \Renci.SshNet\Session.cs:line 612
   Renci.SshNet.Channels.Channel.Dispose(Boolean disposing) \Renci.SshNet\Channels\Channel.cs:line 626
   Renci.SshNet.Channels.ChannelSession.Dispose(Boolean disposing) \Renci.SshNet\Channels\ChannelSession.cs:line 357
   Renci.SshNet.Channels.Channel.Dispose() \Renci.SshNet\Channels\Channel.cs:line 601

Oct 28, 2011 at 1:49 AM

   Renci.SshNet.Sftp.SftpSession.Dispose(Boolean disposing) \Renci.SshNet\Sftp\SftpSession.cs:line 966
   Renci.SshNet.Sftp.SftpSession.Dispose() \Renci.SshNet\Sftp\SftpSession.cs:line 948
   Renci.SshNet.SftpClient.Dispose(Boolean disposing) \Renci.SshNet\SftpClient.cs:line 1231
   Renci.SshNet.BaseClient.Finalize() \Renci.SshNet\BaseClient.cs:line 276

Nov 4, 2011 at 1:13 PM


Try the latest changset from the Source tab, there is a Download link on the right side. Please let us know if your problem persists.

Nov 7, 2011 at 2:00 PM

I download the changeset 11931

It looks works

thks to kenneth_aa and olegkap

Jan 13, 2012 at 9:33 PM

im having similar problem.

I have Sftp server installed on dev system so it transfers the file but it fails on Disconnect

Using Renci.SshNet.Net35

After doing


  getting Socket exception  in


partial void SocketRead(int length, ref byte[] buffer)


line 71 :var receivedBytes = this._socket.Receive(buffer, offset + receivedTotal, length - receivedTotal, SocketFlags


this._socket is null at that moment.

Jan 17, 2012 at 2:01 PM

Can you reproduce it every single time?

Does it happens with all servers or only with specific SSH server implemention?