Skip to content

Session operation has timed out with version 2023.0.0 ok with 2020.0.2 #1260

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

Closed
Foxsterc opened this issue Dec 7, 2023 · 11 comments
Closed

Comments

@Foxsterc
Copy link

Foxsterc commented Dec 7, 2023

Hi,

I get the following error with version 2023.0.0

Session operation has timed out at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.PrivateKeyAuthenticationMethod.Authenticate(Session session) at Renci.SshNet.AuthenticationMethod.Renci.SshNet.IAuthenticationMethod.Authenticate(ISession session) at Renci.SshNet.ClientAuthentication.TryAuthenticate(ISession session, AuthenticationState authenticationState, String[] allowedAuthenticationMethods, SshAuthenticationException& authenticationException) at Renci.SshNet.ClientAuthentication.Authenticate(IConnectionInfoInternal connectionInfo, ISession session) at Renci.SshNet.ConnectionInfo.Authenticate(ISession session, IServiceFactory serviceFactory) at Renci.SshNet.Session.Connect() at Renci.SshNet.BaseClient.CreateAndConnectSession() at Renci.SshNet.BaseClient.Connect()

With the following code

` var connectionInfo = new ConnectionInfo(this.Host,

                            this.Username,
                            new PrivateKeyAuthenticationMethod(this.Username, new[] { new PrivateKeyFile(this.PrivateKeyPath) }))
            {
                RetryAttempts = 3,


            };



            using SftpClient client = new SftpClient(connectionInfo);



            client.Connect();

`

The same code works fine with version 2020.0.2

Thanks,

@Rob-Hague
Copy link
Collaborator

Rob-Hague commented Dec 8, 2023

Sorry to hear that. Does it happen every time, or sporadically?

There have been some issues reported here #1233 (comment). It might be worth a try. (edit: on second thoughts, that is about authentication, not connection)

@Foxsterc
Copy link
Author

Foxsterc commented Dec 8, 2023

Happens every time, just time out. I have to revert at the minute as it's in production.

@Rob-Hague
Copy link
Collaborator

If you are motivated to troubleshoot (understandable if not), the most definitive way would be to run a packet capture and observe differences between the old version and new. With Wireshark it's possible to filter on SSH packets https://wiki.wireshark.org/SSH.md

@Rob-Hague
Copy link
Collaborator

@Foxsterc would be interested to know if you still have issues on the latest develop branch (after 2b53e46) or not

@AdalbertKhoolsaat
Copy link

Would like to add that although I use a different setup, I'm experiencing the same issue after upgrading from 2020.0.2 to 2023.0.0.

Client setup similar to this:

var client = new SftpClient(myEndpoint, myPort, myUser, myPassword);

client.HostKeyReceived += (sender, e) =>
{
using SHA256 sha256Hasher = SHA256.Create();
var sha256Fingerprint = Convert.ToBase64String(sha256Hasher.ComputeHash(e.HostKey));
e.CanTrust = sha256Fingerprint == myKnownSshHostKeyFingerprint.Split(' ')[^1];
};

I now see a version 2023.0.1 got released a few days ago. Does that one contain a potential fix?

@Rob-Hague
Copy link
Collaborator

@AdalbertKhoolsaat please try 2023.0.1 and report back, thanks

@WojciechNagorski
Copy link
Collaborator

The 2023.0.1 version contains fixes that can help you. Please try new version.

@AdalbertKhoolsaat
Copy link

Alright, I have upgraded to the latest version but with mixed results. Debugging locally on a Windows machine it works, but once deployed on AWS Lambda (i.e. Amazon Linux 2) the issues still persist, albeit with a somewhat different error:

Renci.SshNet.Common.SshOperationTimeoutException: Connection failed to establish within 30000 milliseconds.
   at Renci.SshNet.Abstractions.SocketAbstraction.ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSpan connectTimeout, Boolean ownsSocket)
   at Renci.SshNet.Connection.ConnectorBase.SocketConnect(String host, Int32 port, TimeSpan timeout)
   at Renci.SshNet.Connection.DirectConnector.Connect(IConnectionInfo connectionInfo)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.CreateAndConnectSession()
   at Renci.SshNet.BaseClient.Connect()
   ...
   ..
   .

This setup worked without issues on 2020.0.2, so next attempt will be downgrading (for now).

@AdalbertKhoolsaat
Copy link

Alright, I have upgraded to the latest version but with mixed results. Debugging locally on a Windows machine it works, but once deployed on AWS Lambda (i.e. Amazon Linux 2) the issues still persist, albeit with a somewhat different error:

Renci.SshNet.Common.SshOperationTimeoutException: Connection failed to establish within 30000 milliseconds.
   at Renci.SshNet.Abstractions.SocketAbstraction.ConnectCore(Socket socket, IPEndPoint remoteEndpoint, TimeSpan connectTimeout, Boolean ownsSocket)
   at Renci.SshNet.Connection.ConnectorBase.SocketConnect(String host, Int32 port, TimeSpan timeout)
   at Renci.SshNet.Connection.DirectConnector.Connect(IConnectionInfo connectionInfo)
   at Renci.SshNet.Session.Connect()
   at Renci.SshNet.BaseClient.CreateAndConnectSession()
   at Renci.SshNet.BaseClient.Connect()
   ...
   ..
   .

This setup worked without issues on 2020.0.2, so next attempt will be downgrading (for now).

Turns out this error was caused by additional changes related to our provisioning on AWS (specifically, the Lambda had been placed inside a VPC). When put outside the VPC everything works as expected again using version 2023.0.1.

@Rob-Hague
Copy link
Collaborator

Glad you got it sorted

@Foxsterc I will close this one for now, but if you still see the same issue on 2023.0.1 feel free to re-open

@Foxsterc
Copy link
Author

Foxsterc commented Jan 4, 2024

Apologies @Rob-Hague I've been away. I'm not in a position to test it ay the moment but I will try it as soon as I can.

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