EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SimpleSSH and SimpleSFTP Open() hangs when server is down

Posted: 07/05/2010 23:35:27
by Vincent Parrett (Standard support level)
Joined: 01/17/2008
Posts: 20

We've recently moved from SBB 7 to 8 and have noticed a difference in behaviour.

Under 7, if the SSH host is down an exception is thrown. Under 8, it hangs at the Open() method. This is for both SSHSimpleClient and SFTPSimpleClient.

The problem can be reproduced in using the sample app below. When the 7.x assemblies are referenced, the exception is caught. When the 8.x assemblies are referenced the app hangs at

I had a look at the help and couldn't see a way to set a timeout on the client object.

Is there a method or property that I can set to cause Open() throw an exception (or event) when the server is unavailable?


static void Main(string[] args)
   TElSimpleSSHClient client = new TElSimpleSSHClient();
   client.Address = "";
   client.Username = "ben";
   client.Password = "password";
   client.AuthenticationTypes = SBSSHConstants.Unit.SSH_AUTH_TYPE_PASSWORD;

   client.KeyStorage = new TElSSHMemoryKeyStorage();
   client.OnKeyValidate += new SBSSHCommon.TSSHKeyValidateEvent(client_OnKeyValidate);
   client.OnError += new SBSSHCommon.TSSHErrorEvent(client_OnError);

   Console.WriteLine("About to open a connection");
      Console.WriteLine("Openned a connection");
   catch (Exception e)
      Console.WriteLine("Exception caught: " + e.Message);


static void client_OnError(object Sender, int ErrorCode)
   Console.WriteLine("Error: " + ErrorCode);

static void client_OnKeyValidate(object Sender, TElSSHKey ServerKey, ref bool Validate)
   Validate = true;
Posted: 07/06/2010 02:42:38
by Ken Ivanov (Team)

Thank you for contacting us.

Could you please specify the exact error message you are getting with SBB7 (the message may vary depending on the environment)?

Please use the SocketTimeout property to specify connection timeout in milliseconds.
Posted: 07/06/2010 03:16:48
by Ken Ivanov (Team)

Please ignore my question about the error message, we were able to reproduce the problem here in our environment. The issue is being fixed at the moment. The fix will be available along with the future build update.

Meanwhile, please set SocketTimeout to a non-zero value to bypass the issue. As a matter of fact, using zero socket timeout is not a good practice, as it may lead to long-term hangups under some conditions (caused by the internals of TCP/IP).
Posted: 07/06/2010 19:37:20
by Vincent Parrett (Standard support level)
Joined: 01/17/2008
Posts: 20

Thanks for the quick response. Setting SocketTimeout is a viable work-around until the fix is available.

I have a related, but different question. From my testing it seems that if the server terminates the connection, the client.Active property remains true. The only way I've found to see if the connection is actually active is to try to use it, can catch any resulting exception.

Is there a way to force SimpleSSHClient and SimpleSFTPClient to re-evaluate the Active property?

Posted: 07/07/2010 00:34:18
by Ken Ivanov (Team)

Due to the nature of TCP/IP protocol stack, it is not possible to detect whether connection is alive without trying to send something to it or to read from it.

Your task can actually be achieved with the use of keep-alive signals. Please set the KeepAlivePeriod property to the desired period of keep-alive requests (in milliseconds). This will let the component attempt to send some data to the channel periodically and detect connection shutdown in that way.



Topic viewed 1363 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!