SSH Serial Connection Hangup - WeOnlyDo Discussion board

SSH Serial Connection Hangup (wodSSH / wodSSH.NET)

by Mike D, Wednesday, November 19, 2014, 03:08 (1096 days ago)

I have a asynchronous session that i connect to device. When i get the command prompt, i need to run the command microcom below to open a serial connection to an attached cisco device. A problem arises when there is nothing connected, when i run the command my entire application will hang and freeze up. The command seems to execute but never returns.

microcom -s 9600 /dev/ttyO0

I was thinking about creating a synchronous utility class to log in and test the serial connection. Is there a way to set a time interval on a send command and if it does hang, just force a disconnect on the session?

SSH Serial Connection Hangup

by Jasmine, Wednesday, November 19, 2014, 07:21 (1096 days ago) @ Mike D

Hi Mike.

In my opinion, Timeout property should help you since it will disconnect the session due to inactivity. Set it to some value such as 30 seconds, and when nothing is received in 30 seconds, wodSSH will disconnect.

Would that help?

Warm regards,
Jasmine.

SSH Serial Connection Hangup

by Mike D, Thursday, November 20, 2014, 06:03 (1095 days ago) @ Jasmine

The microcom command itself will create a lock file and can hold the connection waiting for a response. It will lock a Putty session with the same command, only executing ctrl+X and ctrl+C can break out of it. Unfortunately, these commands are not captured in the same way here.

I am trying to create an asynchronous terminal session, similar to Putty, so that the user can enter and receive response freely. Initially i need to automatically execute the create session command. If I set the timeout to 30 seconds to the connection, it will prevent the locked response, however this will be applied to the user's interaction and he will receive the "timeout expired" error if there is a delay in activity.

Is there a way to apply a timeout for an individual command/response, instead of having it globally applied to all commands in a connection?

SSH Serial Connection Hangup

by Jasmine, Thursday, November 20, 2014, 15:42 (1095 days ago) @ Mike D

Hi Mike.

Do you use Blocking = True or Blocking = False? If you're using no Blocking (False), then Receive (and other) methods will not block and will return immediately even if there's nothing in the queue, so you can than try later on to see if new data arrives.

Would that work?

Best regards,
Jasmine.

SSH Serial Connection Hangup

by Mike D, Thursday, December 04, 2014, 04:09 (1081 days ago) @ Jasmine

No, it seems like the connection will get tied up, but this is similar weird behavior found in the putty reponse. The only thing that will break it in putty is Ctrl X + Ctrl C. Is there a way i can send the equivalent using the ssh send command?

SSH Serial Connection Hangup

by Jasmine, Thursday, December 04, 2014, 09:42 (1081 days ago) @ Mike D

Hi Mike.

Yes, you can. Just send chr$(24) for X, and chr$(3) for C. So, sending raw bytes indexed at 24 and 3 is same as CTRL+X and CTRL+C

Hope this will help!
Jasmine.