Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connect hangs forever #798

Closed
drwtsn32x opened this issue Mar 20, 2021 · 4 comments
Closed

Connect hangs forever #798

drwtsn32x opened this issue Mar 20, 2021 · 4 comments
Milestone

Comments

@drwtsn32x
Copy link

Sometimes the Connect() method will hang forever. I notice this happens when I reboot the SSH server. (My program that uses this library will automatically try to reconnect after a disconnection, and it's at this point when it hangs forever.)

Adjusting ConnectionInfo.Timeout has no effect on this problem.

Any ideas?

@jgarciadelanoceda
Copy link

jgarciadelanoceda commented Apr 8, 2021

Same happens to me.
I updated from version 2016.1.0 to 2020.0.1 and with some machines Connection hang forever in new version whereas with old version connection was a successfull one.

This is the method I use for connecting:
@params.sshClient = new Renci.SshNet.SshClient(@params.connectionAsEvent.connection.Ip.Trim(), @params.GetPort() ?? 22, @params.GetUser(), @params.GetPassword()); @params.sshClient.Connect(); @params.shellStream = @params.sshClient.CreateShellStream("xterm", 80, 600, 0, 0, 32 * 1024);

And this is the exception it gave:
Error Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.CreateAndConnectSession() at Renci.SshNet.BaseClient.Connect()

likeMyCoffee added a commit to likeMyCoffee/SSH.NET that referenced this issue Jun 29, 2021
Certain Cisco devices do not adhere to RFC4342 and do not reply if the client identifies first.
Since identifcation can be in random order it will give random connection issues because the SSH_MSG_KEXINIT will not be sent if the client is faster.

Since SSH.Net is not at fault and compatibility with Cisco (and possibly other) devices is something that can easily be supported I've written this modification.

Added LazyIdentification to the ConnectionInfo object to allow late identification in ProtocolVersionExchange.
Overloaded 'Start' function to keep the original functionality and tests intact.

Highly likely fixes issues sshnet#752, sshnet#778, sshnet#469 and might help with sshnet#798, sshnet#767, sshnet#807
likeMyCoffee added a commit to likeMyCoffee/SSH.NET that referenced this issue Jun 29, 2021
Certain Cisco devices do not adhere to RFC4342 and do not reply if the client identifies first.
Since identifcation can be in random order it will give random connection issues because the SSH_MSG_KEXINIT will not be sent if the client is faster.

Since SSH.Net is not at fault and compatibility with Cisco (and possibly other) devices is something that can easily be supported I've written this modification.

Added LazyIdentification to the ConnectionInfo object to allow late identification in ProtocolVersionExchange.
Overloaded 'Start' function to keep the original functionality and tests intact.

Highly likely fixes issues sshnet#752, sshnet#778, sshnet#469 and might help with sshnet#798, sshnet#767, sshnet#807
@WojciechNagorski
Copy link
Collaborator

It's done in #1274

@WojciechNagorski WojciechNagorski added this to the 2023.0.1 milestone Dec 21, 2023
@WojciechNagorski
Copy link
Collaborator

The 2023.0.1 version has been released to Nuget: https://www.nuget.org/packages/SSH.NET/2023.0.1

@kazykenov
Copy link

kazykenov commented Jan 9, 2024

This experiencing this issue with the latest version of the library (2023.0.1)
In my case it freezes on file open.

It happens once in 1-2 days. I'm connecting to the files served by this docker container https://github.com/atmoz/sftp on Azure VM

innermostType
Renci.SshNet.Common.SshOperationTimeoutException
innermostMessage
Operation has timed out.
innermostAssembly
Renci.SshNet, Version=2023.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106
innermostMethod
Renci.SshNet.SubsystemSession.WaitOnHandle
{"assembly":"Renci.SshNet, Version=2023.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106","method":"Renci.SshNet.SubsystemSession.WaitOnHandle","level":0,"line":0}
1
{"assembly":"Renci.SshNet, Version=2023.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106","method":"Renci.SshNet.Sftp.SftpSession.RequestOpen","level":1,"line":0}
2
{"assembly":"Renci.SshNet, Version=2023.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106","method":"Renci.SshNet.Sftp.SftpFileStream..ctor","level":2,"line":0}
3
{"assembly":"Renci.SshNet, Version=2023.0.1.0, Culture=neutral, PublicKeyToken=1cee9f8bde3db106","method":"Renci.SshNet.SftpClient.OpenRead","level":3,"line":0}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants