Inconsistent connection failures (General questions)
I am having issues with inconsistent results when connection to an FSecure SSH server with WODSSH.NET (version 2.2.1.50). When it works, it works fine, when it fails it always happens on the WaitFor( > ) when I am checking to make sure we are ready to send commands. I don't have any issues with any other clients such as FSecure's client and putty. The windows 2003 machine running FSecure server has the following config:
EmulationType stream
EmulationTypeForForcedCommand raw
EmulationTypeForCommands stream
Below is the code I am using which encounters failrues only part of the time. Btw, extending the timeout does not help. Any suggestions?
int success = 0;
int failure = 0;
for(int i = 0; i < 10; i++)
{
SSH _sshClient = null;
try
{
_sshClient = new SSH();
_sshClient.LicenseKey = GetLicKey();
_sshClient.Hostname = GetServerName();
_sshClient.Login = GetID();
_sshClient.Password = GetPassword();
_sshClient.Protocol = SSH.SupportedProtocols.SSHAuto;
_sshClient.Timeout = 10;
_sshClient.Blocking = true;
_sshClient.Prompt = > ;
_sshClient.PromptReceivedEvent += new WeOnlyDo.Client.SSH.PromptReceivedDelegate(_sshClient_PromptReceivedEvent);
_sshClient.DataReceivedEvent += new WeOnlyDo.Client.SSH.DataReceivedDelegate(_sshClient_DataReceivedEvent);
_sshClient.StateChangedEvent += new WeOnlyDo.Client.SSH.StateChangedDelegate(_sshClient_StateChangedEvent);
_sshClient.ShowStdErrorMessages = true;
Trace.WriteLine( Establishing connection );
_sshClient.Connect();
Trace.WriteLine( Beginning WaitFor );
//this wait just removes the prompt data from the result
Trace.WriteLine(_sshClient.WaitFor( > ));
Trace.WriteLine( Beginning Execute );
Trace.WriteLine(_sshClient.Execute( cd ..
, > ));
Trace.WriteLine( 2nd Command Execute );
Trace.WriteLine(_sshClient.Execute( dir
, > ));
Trace.WriteLine( Execute Completed );
success++;
_sshClient.Disconnect();
}
catch(Exception ex)
{
failure++;
Trace.WriteLine( Exception: + ex.Message);
Process.Start(@ c: empSSHDebug.txt );
}
}
Trace.WriteLine( Success = + Convert.ToString(success) +
Failures = + Convert.ToString(failure));