0 votes
by (380 points)

Hello.

I have a problem using the Rebex.TerminalEmulation.Scripting.Timeout property. Our application worked in production mode from november 2016 to april 2017 without any errors. But we get error now.

Here is a code sample which reproduce the error:

try
{
    var ssh = new Ssh();

    ssh.Connect(Settings.Host, Settings.Port);
    ssh.Login(Settings.User, Settings.Password);

    Scripting shell = ssh.StartScripting();

    shell.Timeout = 1000 * 60 * 60; // 1 hour!!!!!!
    shell.Terminal.Options.Encoding = Encoding.UTF8;

    shell.DetectPrompt();

    shell.SendCommand("ls -al");

    shell.Close();

    ssh.Disconnect();
}
catch (Exception e)
{
    /*
    System.ArgumentOutOfRangeException: Number must be either non-negative and less than or equal to Int32.MaxValue or -1.
    at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
    at Rebex.Net.SshSession.DGV[C,V](TTG`2 C, Int32 V, ITG Z, V N, C Q, C M)
    at Rebex.Net.SshChannel.ZZ(Int32 C)
    at Rebex.Net.SshChannel.KZ(Int32 C, SocketSelectMode V)
    at Rebex.Net.ZRG.Poll(Int32 microSeconds)
    at Rebex.TerminalEmulation.WAG.GV(Int32 C)
    at Rebex.TerminalEmulation.WAG.TV(Int32 C)
    at Rebex.TerminalEmulation.ICN.ZV(Int32 C)
    at Rebex.TerminalEmulation.Scripting.RV(Int32 C)
    at Rebex.TerminalEmulation.Scripting.LV(ScriptEvent C)
    at Rebex.TerminalEmulation.Scripting.EZ(String C)
    at Rebex.TerminalEmulation.Scripting.SendCommand(String command)
    */
}

If the the timeout value is reduced to about 30 minutes, the sample code works without any errors.

I personally can reproduce the problem on the Debian 7.5 system.
https://cdimage.debian.org/mirror/cdimage/archive/7.5.0-live/amd64/iso-hybrid/debian-live-7.5.0-amd64-standard.iso

But we have information, that the same problem are on Debian 7, SUSE Enterprise Linux Desktop 11 and Oracle Linux 6 systems.

In the production mode we are using the Rebex SSH Pack (Beta Build 6165). The beta build contains the "two step routine" feature.
http://forum.rebex.net/6585/ssh-rsa-keys-authentication-issue

But that the same problem is on the Rebex SSH Pack (2017 R3).

Here is a part of a log file

2017-05-17 14:07:34.185 DEBUG VirtualTerminal(0)[10] Scripting: SendCommand(ls -al)
2017-05-17 14:07:34.186 VERBOSE Ssh(3)[10] SSH: Sending packet SSH_MSG_CHANNEL_DATA (16 bytes).
 0000 |5E-00-00-00-00-00-00-00 07-6C-73-20-2D-61-6C-0D| ^........ls -al.
2017-05-17 14:07:34.186 DEBUG Ssh(3)[10] Info: Sent 7 bytes of data.
2017-05-17 14:07:34.186 VERBOSE Ssh(3)[10] Info: Sent data: 
 0000 |6C-73-20-2D-61-6C-0D                           | ls -al.
2017-05-17 14:07:34.186 DEBUG VirtualTerminal(0)[10] Scripting: WaitFor(Line)
2017-05-17 14:07:34.186 VERBOSE VirtualTerminal(0)[10] Scripting: WaitFor: polling data for max 3600000 ms.
2017-05-17 14:07:34.187 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (17 bytes).
 0000 |5E-00-00-00-00-00-00-00 08-6C-73-20-2D-61-6C-0D| ^........ls -al.
 0010 |0A                                             | .
2017-05-17 14:07:34.188 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (17 bytes).
 0000 |5E-00-00-00-00-00-00-00 08-74-6F-74-61-6C-20-32| ^........total 2
 0010 |30                                             | 0
2017-05-17 14:07:34.188 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
2017-05-17 14:07:34.195 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (52 bytes).
 0000 |5E-00-00-00-00-00-00-00 2B-64-72-77-78-2D-2D-2D| ^.......+drwx---
 0010 |2D-2D-2D-20-20-32-20-72 6F-6F-74-20-72-6F-6F-74| ---  2 root root
 0020 |20-34-30-39-36-20-4D-61 79-20-31-37-20-30-34-3A|  4096 May 17 04:
 0030 |32-30-20-2E                                    | 20 .
2017-05-17 14:07:34.195 ERROR Ssh(3)[10] SSH: 
System.ArgumentOutOfRangeException: Number must be either non-negative and less than or equal to Int32.MaxValue or -1.
Parameter name: millisecondsTimeout
at System.Threading.WaitHandle.WaitOne(Int32 millisecondsTimeout, Boolean exitContext)
at Rebex.Net.SshSession.DGV[C,V](TTG`2 C, Int32 V, ITG Z, V N, C Q, C M)
at Rebex.Net.SshChannel.ZZ(Int32 C)
at Rebex.Net.SshChannel.KZ(Int32 C, SocketSelectMode V)
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (53 bytes).
 0000 |5E-00-00-00-00-00-00-00 2C-64-72-77-78-72-2D-78| ^.......,drwxr-x
 0010 |72-2D-78-20-32-33-20-72 6F-6F-74-20-72-6F-6F-74| r-x 23 root root
 0020 |20-34-30-39-36-20-4D-61 79-20-31-37-20-30-34-3A|  4096 May 17 04:
 0030 |31-35-20-2E-2E                                 | 15 ..
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
 2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (64 bytes).
 0000 |5E-00-00-00-00-00-00-00 37-2D-72-77-2D-2D-2D-2D| ^.......7-rw----
 0010 |2D-2D-2D-20-20-31-20-72 6F-6F-74-20-72-6F-6F-74| ---  1 root root
 0020 |20-20-33-37-31-20-4D-61 79-20-31-37-20-30-37-3A|   371 May 17 07:
 0030 |30-34-20-2E-62-61-73-68 5F-68-69-73-74-6F-72-79| 04 .bash_history
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (58 bytes).
 0000 |5E-00-00-00-00-00-00-00 31-2D-72-77-2D-72-2D-2D| ^.......1-rw-r--
 0010 |72-2D-2D-20-20-31-20-72 6F-6F-74-20-72-6F-6F-74| r--  1 root root
 0020 |20-20-35-37-30-20-4A-61 6E-20-33-31-20-20-32-30|   570 Jan 31  20
 0030 |31-30-20-2E-62-61-73-68 72-63                  | 10 .bashrc
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (59 bytes).
 0000 |5E-00-00-00-00-00-00-00 32-2D-72-77-2D-72-2D-2D| ^.......2-rw-r--
 0010 |72-2D-2D-20-20-31-20-72 6F-6F-74-20-72-6F-6F-74| r--  1 root root
 0020 |20-20-31-34-30-20-4E-6F 76-20-31-39-20-20-32-30|   140 Nov 19  20
 0030 |30-37-20-2E-70-72-6F-66 69-6C-65               | 07 .profile
2017-05-17 14:07:34.196 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (11 bytes).
 0000 |5E-00-00-00-00-00-00-00 02-0D-0A               | ^..........
2017-05-17 14:07:34.211 VERBOSE Ssh(3)[16] SSH: Received packet SSH_MSG_CHANNEL_DATA (24 bytes).
 0000 |5E-00-00-00-00-00-00-00 0F-72-6F-6F-74-40-64-65| ^........root@de
 0010 |62-69-61-6E-3A-7E-23-20                        | bian:~# 

1 Answer

+1 vote
by (15.2k points)
edited by
 
Best answer

Hello, thank you for this report. Although this long timeout is questionable, it is surely a bug on our side. We were able to trace it and make a hotfix. I will send you full hotfix version of SSHPack 2017 R3 tommorow once it is ready from our support mail. For future users, in the same time I will post a link to trial version of the same build here.

Update: Rebex SSH Pack 2017 R4 fixes this: https://www.rebex.net/ssh-pack/history.aspx#2017R4

...