I am running several commands in sequence (each command is a separate ssh session) to install a service on RH/CentOS (5 and 6) via openssh and the last command to start the service seems to always timeout, regardless of which timeout value (it always reaches the timeout). Here are the basics:
rpm -i <package>
the following commands are running a batch script (provided with service)
accept EULA
set License key
adduser
start daemon (via init script)
Results:
SSH Operation timed out with 'Renci.SshNet.Common.SshOperationTimeoutException: Command '/etc/init.d/<daemon> start 2>&1' has timed out. at Renci.SshNet.SshCommand.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.SshCommand.EndExecute(IAsyncResult asyncResult)
I saw a couple threads regarding the WaitOnHandle hanging? But wasn't too clear on the resolution, or if there is one. I can run the commands from a local shell and not encounter the timeout (which is currently set to 90s). I haven't got to the point of debugging yet, so I am just handling it as the daemon does get started. The remote server logs indicate the service gets started and takes only a couple seconds (also in my manual testing). Just checking to see if this is a known issue since I don't have a ton of time to track it down.
Thanks a ton, this library is quite useful.
Dave
Here is the code:
rpm -i <package>
the following commands are running a batch script (provided with service)
accept EULA
set License key
adduser
start daemon (via init script)
Results:
SSH Operation timed out with 'Renci.SshNet.Common.SshOperationTimeoutException: Command '/etc/init.d/<daemon> start 2>&1' has timed out. at Renci.SshNet.SshCommand.WaitOnHandle(WaitHandle waitHandle) at Renci.SshNet.SshCommand.EndExecute(IAsyncResult asyncResult)
I saw a couple threads regarding the WaitOnHandle hanging? But wasn't too clear on the resolution, or if there is one. I can run the commands from a local shell and not encounter the timeout (which is currently set to 90s). I haven't got to the point of debugging yet, so I am just handling it as the daemon does get started. The remote server logs indicate the service gets started and takes only a couple seconds (also in my manual testing). Just checking to see if this is a known issue since I don't have a ton of time to track it down.
Thanks a ton, this library is quite useful.
Dave
Here is the code:
using (SshClient client = new SshClient(GetConnectionInfo(thisServer)))
{
if (timeoutInSeconds > 0)
client.ConnectionInfo.Timeout = TimeSpan.FromSeconds(timeoutInSeconds);
client.Connect();
var command = client.CreateCommand(cmdLine);
command.CommandTimeout = TimeSpan.FromSeconds(timeoutInSeconds);
command.Execute();
cmdOutput = String.IsNullOrEmpty(command.Error) ? command.Result : command.Error;
Log.Verbose("ExecuteCmd('{0}')", cmdLine);
Log.Verbose(" -- return code: '{0}'", command.ExitStatus);
Log.Verbose(" -- standard out: '{0}'", string.IsNullOrEmpty(command.Result) ? "" : command.Result);
Log.Verbose(" -- standard err: '{0}'", string.IsNullOrEmpty(command.Error) ? "" : command.Error);
return command.ExitStatus;
}