SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

TIMEOUT parameter for ConnectionInfo is not working (SSHClient)

Open boukenka opened this issue 10 years ago • 7 comments

Hello,

I have tried the following coding:

List<AuthenticationMethod> AuthenticationMethods = new List<AuthenticationMethod>();
AuthenticationMethods.Add(new PasswordAuthenticationMethod(username, password));
ConnectionInfo ConnectionInfo = new ConnectionInfo(IPAddress, port, username, 
AuthenticationMethods.ToArray());
ConnectionInfo.Timeout = new TimeSpan(0, 0, 50);
SshClient SshClient = new SshClient(ConnectionInfo);
SshClient.Connect();

There is a failure to reach the IP address. But the time out is not respected. There is an exception after 20/30 seconds (approximately). Is there something wrong in my coding?

Thanks

PS: I have tried with the last version of SSH.NET project (development) and the official one. PS: In the definition of the project for SSH.NET, it is written: this.Timeout = TimeSpan.FromSeconds(30); PS: I have also tried the example in the SSH.NET project. It was the same result.

var host = Resources.HOST;
var username = Resources.USERNAME;
var password = Resources.PASSWORD;
#region Example SshClient Connect Timeout
var connectionInfo = new PasswordConnectionInfo(host, username, password);
connectionInfo.Timeout = TimeSpan.FromSeconds(50);
using (var client = new SshClient(connectionInfo))
{
     client.Connect();
     //  Do something here
     client.Disconnect();
}

boukenka avatar Dec 03 '16 10:12 boukenka

Good evening. Is it possible to get any feedback about that question please? Also to have an example of coding for the "SCPClient and Port Forwarding" request please.

boukenka avatar Dec 20 '16 16:12 boukenka

Can you post information about exception that you get?

Thanks, Oleg

olegkap avatar Dec 20 '16 18:12 olegkap

Here is the information that I get:

Additional information: A connection attempt failed because the connected party did 
not properly respond after a period of time, or established connection failed because 
connected host has failed to respond.

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in 
Renci.SshNet.dll.

SocketErrorCode : TimedOut

It is happening after 20 seconds even the timeout is set to 55 seconds like below:

SshClient.ConnectionInfo.Timeout = new TimeSpan(0, 0, 55);

boukenka avatar Dec 21 '16 17:12 boukenka

Is it possible to get an update please? Any possible change for the implementation? Or do I use it wrongly?

boukenka avatar Dec 28 '16 17:12 boukenka

Good evening. Is it possible to get an update please?

boukenka avatar Jan 16 '17 20:01 boukenka

@boukenka please check my answer over here #183

kasbst avatar May 04 '17 19:05 kasbst

Thanks for the clarification.

boukenka avatar May 04 '17 20:05 boukenka