SSH.net Exception :: Timeout occurred due to inact - WeOnlyDo Discussion board

SSH.net Exception :: Timeout occurred due to inact (wodSSH / wodSSH.NET)

by Jairo Martinez, Wednesday, July 25, 2012, 20:25 (4504 days ago)

So i am having this response most of the time in conjunction with using the Execute() Method.

(one other thing -- i am very very green to the software development world. If any of you out there are familiar with AMX System Control hardware, this is the type of programming i am familiar with (kinda of like C, but with its very significant differences).

TO START ->

Here is a quick break down of my assignment, my program and its environment:

I was task with the job of creating of what is called the VC Connector . Its task is to do the following:

Connect to (up to) 230 video conferencing systems (ie CODECS) via ssh providing back the functions of: Call, Disconnect, Call Status, Camera Control, Volume Control, Content Sharing, Microphone Muting.
These functions will be available via a Web/HTTP service that will be constantly accesses from another program (written by others) that will consume those a fore mention functions.

There are two Manufactures of VTC Codecs being used: Cisco Tele-Presence (CTS) Codecs.
Tandberg C-Series and EX-Series Codecs (Now owned by Cisco)

The Program: (Where the ssh.net library comes in)
I have written a class that will be used to create each VTC (codec) object. Inside the class, i use the ssh.net library.

So, for each instance of my VTC class, an instance of the ssh.net library is created inside that object.


The hardware limitations of Cisco CTS codecs:
Whenever you connect to a Cisco CTS codec, it can take up to 15 to 20 seconds to log-in before you can issue a command. When it is ready, the prompt is basically this: admin:

Now the really issue: When you execute a command to a Cisco CTS Codec, it can take from 3 to 10 seconds before you get a reply message back.

But on top of that, it may between .5 to 1 second after you receive the response message, before you get the prompt of admin: back. Plus, during its long reply time, NO COMMAND can be sent while waiting for the prompt to return.

This is where I need help to understand what is going inside the ssh.net library.

ssh.net library version -> 2.5.4.141

To begin, here is my constructor:

ssh = new SSH();
ssh.LicenseKey = xxxx-xxxx-xxxx-xxxx ; ( Don't want to share my key with everyone :) )
ssh.Hostname = this.ipAddress;
ssh.Login = this.user;
ssh.Password = this.pass;

ssh.DebugFile = @ G: acconnectorssh_logsssh_ + this.e164number + .log ;
ssh.Compression = 6;
ssh.Protocol = SSH.SupportedProtocols.SSHAuto;
ssh.Blocking = true;

ssh.Timeout = 1800;

ssh.DataReceivedEvent += new SSH.DataReceivedDelegate(sshDataReceivedEvent);
ssh.StateChangedEvent += new SSH.StateChangedDelegate(sshStateChangedEvent);
ssh.DisconnectedEvent += new SSH.DisconnectedDelegate(ssh_DisconnectedEvent);

so when I use my instance of the ssh library (which I cleverly call ssh ) i am doing this: (example)

try
{
string prompt = admin: ;
string cmd = call state
;
string str = ssh.Execute(cmd,prompt); (--> I have also used the third parameter of time setting it to 30 which i assume is 30 seconds.)
}
catch(Exception ex)
{
printLn(ex.Message);
}

The following is an excerpt from my own logs:

INFO ,2012-07-25 11:14:55,TAC : -> Call? : VTC #036 (143.3.230.85)
INFO ,2012-07-25 11:14:55,VTC : -> #036 :: -> GetStatus() Request
INFO ,2012-07-25 11:14:55,VTC : -> #036 :: -> Execute() Request
ERROR,2012-07-25 11:15:11,VTC : !! #036 :: Execute(22) Exception :: Timeout occurred due to inactivity.

INFO ,2012-07-25 11:15:36,TAC : -> Call? : VTC #036 (143.3.230.85)
INFO ,2012-07-25 11:15:36,VTC : -> #036 :: -> GetStatus() Request
INFO ,2012-07-25 11:15:36,VTC : -> #036 :: -> Execute() Request
ERROR,2012-07-25 11:15:52,VTC : !! #036 :: Execute(179) Exception :: Timeout occurred due to inactivity.

(Where is it getting the roughly 16 second timeout from?)
----------------
Now, the log service that is built in the ssh.net library is to simple, in that it does not provide alot of information such as:
-The time a command went out and when/or if it w

Re: SSH.net Exception :: Timeout occurred due to i

by wodDamir, Wednesday, July 25, 2012, 21:33 (4504 days ago) @ Jairo Martinez

Hi Jairo,

Actually, the exception is thrown since wodSSH.Netnever receives the prompt specified.

However, what happens if you try something like this:

ssh.WaitFor( admin: , 10);
ssh.DataReady = 0;
ssh.Execute( call state\r\n , admin: , 10);

Please note that when 3rd parameter (timeout) is specified, component will not disconnect. It will proceed with the code (provided that you have global Timeout property set to higher value).

Regards,
Damba

Re: SSH.net Exception :: Timeout occurred due to i

by digimenet, Wednesday, July 25, 2012, 22:13 (4504 days ago) @ wodDamir

A couple questions:

1: the method WaitFor() returns a value which is (other than that it is a string)? Is is it data that maybe sitting in the queue that I need to collect before setting the DataReady property?
ssh.WaitFor( admin: , 10);


2. the DataReady property, setting it to 0 does what? clear out old data?
ssh.DataReady = 0;

3. though this is the typical method i use, calling it after WaitFor() is a bit confusing. Also, is 10 for 10 seconds, i assume?
ssh.Execute( call state
, admin: , 10);

PS - this is Jairo Martinez, now with a user name....

Re: SSH.net Exception :: Timeout occurred due to i

by wodDamir, Wednesday, July 25, 2012, 22:40 (4504 days ago) @ digimenet

Jairo,

WaitFor returns everything it received up until the Prompt.

Setting Dataready to 0 ensures that there is no leftover data in buffer.

As for the 3rd question, calling WaitFor makes sure that data is pulled from buffer. Calling execute now will return only the data that was received by the command sent in Execute call.

The 3rd parameter in Execute call is Timeout parameter, in seconds. It's the time component will wait until proceeding with the code.

Regards,
Damba