Inconsistent connection failures - WeOnlyDo Discussion board

Inconsistent connection failures (General questions)

by ddeloveh, Wednesday, May 10, 2006, 17:40 (6772 days ago)

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));

Re: Inconsistent connection failures

by wodAlan, Wednesday, May 10, 2006, 22:16 (6771 days ago) @ ddeloveh

Hi,

Sorry for long wait, but I lose some time with installing WIN 2003.
So, I just tried to duplicate this problem and here is my test and my results:

1. Server WIN 2003 Fsecure
2. Client WIN XP and WIN 2003 wodSSH.NET (version 2.2.1.50)

I think that I able to duplicate this, but in my case I get this every time when I try to connect.
I used some similarly code like yours but I changed following line:
_sshClient.Prompt = > ;
with:
_sshClient.Prompt = regex:[$ #>] $

Can you try that?

Hope I helped.

Regards,
Alan

Re: Inconsistent connection failures

by ddeloveh, Wednesday, May 10, 2006, 22:51 (6771 days ago) @ wodAlan

Hello Alan,

Thanks for the prompt response, and trust me when I say 4 hours is very good turn around time. Especially when attempting to repro an issue.

I changed to the prompt property and it worked perfectly, which rocks. But raises a number of questions in my mind, both general and specific.
1) Why does it now work when I only set the prompt property to the regex your provided without changing my WaitFor( > ) and Execute(.., > ) call?
2) Should I have changed both?
3) So what is the root cause? Is it a nuance with F-Secure? wodSFTP.NET? the space time continuum? :)
4) Would this have acted differently if I had set a specific TerminalType?
5) Is there a secret decoder document of recomendations for how to configure the component by server type and version?
6) In my environment we have a number of different server types that the componet must be configured for and the end user often struggles with the specific properties to setup within our app which we map to your component. Is it usually safer to let the component auto config most values?

Thanks again,

David

Re: Inconsistent connection failures

by wodAlan, Thursday, May 11, 2006, 00:32 (6771 days ago) @ ddeloveh

David,

1) Why does it now work when I only set the prompt property to the
regex your provided without changing my WaitFor( > ) and Execute(..,
> ) call?
2) Should I have changed both?

You should set regular expression (almost always), but of course you can specify something what satisfy your needs. Also read my answer under question 3.
If you have more than one command to execute on the remote server, you
will find this feature handy.
If Prompt property is set, the command prompt string you entered will
not be provided through the Received event - which means you don't
have to 'cut it out' of the command output and if you set only, under
the Prompt Property ( > ), then you cannot wait same thing. And I
suggest you to use only WaitFor Method in this case.

3) So what is the root cause? Is it a nuance with F-Secure?
wodSFTP.NET? the space time continuum?

No, there is no root cause. You were wait > , but because of speed of connection sometimes sign > come into and Prompt Property catch it and remove it from buffer and then WaitFor Method will wait something what will never come.

4) Would this have acted differently if I had set a specific TerminalType?
The terminal type does not really have any affect on the local side.

5) Is there a secret decoder document of recommendations for how to
configure the component by server type and version?

Unfortunately not. But we are testing wodSSH.NET with lots the most
common servers so I presume that you will have no problem with any,
but of course you can always find one, and in this case we will try
to find solution. :)

6) In my environment we have a number of different server types that
the component must be configured for and the end user often struggles
with the specific properties to setup within our app which we map to
your component. Is it usually safer to let the component auto config
most values?

For example, if you set Protocol Property to Auto it should always
work. But on other side best way is to test with server and specific
properties manually for your needs.

Regards,
Alan