sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.97k stars 933 forks source link

SSH.Net with Dropbear: Session close after 30 minutes #568

Open ganeshkamath89 opened 5 years ago

ganeshkamath89 commented 5 years ago

We are using Dropbear with SSH.Net for an application.

Setup:

Changes attempted:

Environment:

Other test case combinations tried and working so far:

Has anybody faced this kind of disconnection?

Does anyone have any recommendation or workaround for this problem?

msdivy commented 5 years ago

As per - https://stackoverflow.com/questions/38613717/have-i-encountered-an-incompatibility-between-ssh-net-and-dropbear,

Please try changing the buffer size to 8K.

Code copied from above link:

using (var sftp = new SftpClient(connection)) 
{ 
    sftp.BufferSize = 8192; 
    sftp.Connect(); 
    // ...
}
ganeshkamath89 commented 5 years ago

The object of the class SshClient does not have an attribute for Buffer size. I tried hardcoding the values send and receive Buffer, but it did not help.

I am getting the following error @msdivy

SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelCloseMessage' to server: 'SSH_MSG_CHANNEL_CLOSE : #0'.

SshNet.Logging Verbose: 1 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelOpenMessage' to server: 'SSH_MSG_CHANNEL_OPEN'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelOpenConfirmationMessage' from server: 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #827'. SshNet.Logging Verbose: 1 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelRequestMessage' to server: 'SSH_MSG_CHANNEL_REQUEST : #0'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelSuccessMessage' from server: 'SSH_MSG_CHANNEL_SUCCESS : #827'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #827'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelEofMessage' from server: 'SSH_MSG_CHANNEL_EOF : #827'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelRequestMessage' from server: 'SSH_MSG_CHANNEL_REQUEST : #827'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelCloseMessage' from server: 'SSH_MSG_CHANNEL_CLOSE : #827'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelCloseMessage' to server: 'SSH_MSG_CHANNEL_CLOSE : #0'.

SshNet.Logging Verbose: 1 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelOpenMessage' to server: 'SSH_MSG_CHANNEL_OPEN'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelOpenConfirmationMessage' from server: 'SSH_MSG_CHANNEL_OPEN_CONFIRMATION : #828'. SshNet.Logging Verbose: 1 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelRequestMessage' to server: 'SSH_MSG_CHANNEL_REQUEST : #0'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelSuccessMessage' from server: 'SSH_MSG_CHANNEL_SUCCESS : #828'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelDataMessage' from server: 'SSH_MSG_CHANNEL_DATA : #828'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelEofMessage' from server: 'SSH_MSG_CHANNEL_EOF : #828'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelRequestMessage' from server: 'SSH_MSG_CHANNEL_REQUEST : #828'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Received message 'ChannelCloseMessage' from server: 'SSH_MSG_CHANNEL_CLOSE : #828'. SshNet.Logging Verbose: 5 : [2182A24196544768B0D31071155C76D0ABC19F90] Sending message 'ChannelCloseMessage' to server: 'SSH_MSG_CHANNEL_CLOSE : #0'. _session was null.

Exception Location Exception: _session was null. Exception is hit in this block of code: protected SemaphoreLight SessionSemaphore { get { return _session.SessionSemaphore; } } In file SSH.NET\src\Renci.SshNet\Channels\Channel.cs

msdivy commented 5 years ago

Have a look at this: https://github.com/sshnet/SSH.NET/issues/400

ganeshkamath89 commented 5 years ago

Hi @msdivy, the suggestion given in this link caused my application to close sooner. I am running the code from the Development brunch.