Timeout on execSSH command

Post any question you may have in regards to GoAnywhere Director and let our talented support staff and other users assist you.
8 posts Page 1 of 1

Trinity_Chris

Posts: 14
Joined: Wed May 21, 2014 9:00 am

Post by Trinity_Chris » Fri Jul 11, 2014 5:25 am
I've written a project to execute an execSSH task with a timeout but it doesn't seem to work.

Here's the project:
Code: Select all
<project name="Overrun Test" mainModule="Main" version="2.0">
	<description>Test overrun handling</description>
	<variable name="RETURNCODE" value="" />

	<module name="Main">

		<print label="Start" version="1.0">
			<![CDATA[Starting overrun test]]>
		</print>


		<execSSH label="Remote Wait" resourceId="DevServer_SCP" command="~/waiting.sh" commandTimeout="10" returnCodeVariable="RETURNCODE" version="1.0" onError="continue" />


		<print label="ReturnCode" version="1.0">
			<![CDATA[Finished with a return code of ${RETURNCODE}]]>
		</print>


		<print label="End" version="1.0">
			<![CDATA[End overrun test]]>
		</print>

	</module>


	</project>

The script I'm calling is
Code: Select all
#!/usr/bin/sh

echo "Sleeping for 30 seconds \c"
sleep 30
echo done!

And the output I get is:
11/7/14 11:16:55 INFO Start Date and Time: 11/7/14 11:16:55
11/7/14 11:16:55 INFO Job Number: 1000000000182
11/7/14 11:16:55 INFO Project Name: /CE TEST/Overrun Test
11/7/14 11:16:55 INFO Submitted By: chris.evans
11/7/14 11:16:55 INFO GoAnywhere Director 4.6.2 running on Windows Server 2012 6.2 (amd64)
11/7/14 11:16:55 INFO Executing project 'Overrun Test'
11/7/14 11:16:55 INFO Project location: C:\Program Files\Linoma Software\GoAnywhere\userdata\projects\CE TEST\Overrun Test.xml
11/7/14 11:16:55 INFO Executing module 'Main'
11/7/14 11:16:55 INFO Executing task 'print 1.0 (Start)'
11/7/14 11:16:55 INFO Starting overrun test
11/7/14 11:16:55 INFO Finished task 'print 1.0 (Start)'
11/7/14 11:16:55 INFO Executing task 'execSSH 1.0 (Remote Wait)'
11/7/14 11:17:25 INFO Sleeping for 30 seconds done!
11/7/14 11:17:25 INFO The Command executed successfully with return code '0'.
11/7/14 11:17:25 INFO Finished task 'execSSH 1.0 (Remote Wait)'
11/7/14 11:17:25 INFO Executing task 'print 1.0 (ReturnCode)'
11/7/14 11:17:25 INFO Finished with a return code of 0
11/7/14 11:17:25 INFO Finished task 'print 1.0 (ReturnCode)'
11/7/14 11:17:25 INFO Executing task 'print 1.0 (End)'
11/7/14 11:17:25 INFO End overrun test
11/7/14 11:17:25 INFO Finished task 'print 1.0 (End)'
11/7/14 11:17:25 INFO Finished module 'Main'
11/7/14 11:17:25 INFO Finished project 'Overrun Test'
11/7/14 11:17:25 INFO End Date and Time: 11/7/14 11:17:25
What have I done wrong?

C.

Support_Jon

Support Specialist
Posts: 62
Joined: Thu Jul 19, 2012 9:15 am
Location: Ashland, NE

Post by Support_Jon » Fri Jul 11, 2014 9:58 am
Chris,

With the Execute SSH Commands task, the timeout setting is used to specify the number of seconds to wait when establishing a connection to the SSH server. If a connection to that server can not be established in the specified amount of time, an error will be raised to indicate the timeout.

In the case of your project, a connection to the server was established and the command was executed successfully. Placing a sleep in the SSH task will not mimic a connection timeout.

Thanks - Jon

Trinity_Chris

Posts: 14
Joined: Wed May 21, 2014 9:00 am

Post by Trinity_Chris » Tue Jul 15, 2014 3:59 am
Thanks Jon.

How can I limit the execution time of a task?

C.

Support_Jon

Support Specialist
Posts: 62
Joined: Thu Jul 19, 2012 9:15 am
Location: Ashland, NE

Post by Support_Jon » Tue Jul 15, 2014 8:19 am
Chris,

My apologies. I thought you were referencing the Connection Timeout for the SSH server connection. As I review your project again, I see you're talking about the Command Timeout setting.

I will dig into this further today and report back to you.

Thanks - Jon

Jonathan

Posts: 18
Joined: Wed Jan 02, 2013 5:27 am
Location: Mapledurham, UK

Post by Jonathan » Thu Jul 17, 2014 4:42 am
I have just tested this here with a value and without. Rather than running a shell script though I opted for something a bit different:
Code: Select all
while true; do echo foo; sleep 10; done
I would have expected this to have ended after the 5 second timeout or after the 120 default.

Support_Jon

Support Specialist
Posts: 62
Joined: Thu Jul 19, 2012 9:15 am
Location: Ashland, NE

Post by Support_Jon » Thu Jul 17, 2014 11:14 am
Chris,

I did some testing on a few different servers and received results inline with what you and Johnathan have experienced. We will investigate this further and see what can be done to resolve it.

If you could please share with me the specifics on the system you are running the command against, that may prove useful.

Thanks - Jon

Trinity_Chris

Posts: 14
Joined: Wed May 21, 2014 9:00 am

Post by Trinity_Chris » Mon Jul 21, 2014 4:06 am
We're running GoAnywhere on windows and the server we're talking to is AIX

C.

Support_Jon

Support Specialist
Posts: 62
Joined: Thu Jul 19, 2012 9:15 am
Location: Ashland, NE

Post by Support_Jon » Tue Aug 05, 2014 7:57 am
Chris,

We have determined that the Command Timeout setting on the ExecSSH task is incorrectly labeled. It is actually a Channel Connect Timeout and has nothing to do with a command timeout. It's purpose is to specify the maximum time to wait for the channel to be established, in milliseconds. If set to 0, we will wait as long as needed.

Our apologies for any confusion this has caused. We will fix this issue with the next release of GoAnywhere Director so that the label and descriptions accurately reflect the purpose of the setting.


In order to accomplish a true command timeout, you may be able to prepend a timeout command to the front of your command as follows:
sample_timeout.png
sample_timeout.png (11.9 KiB) Viewed 2824 times
Your command script could be something like this:
Code: Select all
#!/bin/bash
while true; do 
echo foo
done
With the timeout specified, the command should finish 5 seconds later with a return code of 124. This means that the timeout command had to stop the process and return.
Code: Select all
30/07/14 8:31:49 AM    INFO    Executing task 'execSSH 1.0'
30/07/14 8:31:54 AM    WARN    The command failed to execute with a return code of '124'.
30/07/14 8:31:54 AM    INFO    Finished task 'execSSH 1.0'
8 posts Page 1 of 1