Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Bob's Blog
has no ratings.
Published: 21 Apr 2011
Revised: 30 Sep 2014 - 54 days ago
Last viewed on: 23 Nov 2014 (10633 views) 
Bob Cozzi's SetKeepAlive.exe - A Fix for Client Access & RDp Timeout Published by: Bob Cozzi on 21 Apr 2011 view comments(2)

Bob Cozzi's Client Access/RDi SetKeepAlive.exe

Solving Disconnect Issues with IBM i Access and RDp/RDi

TCP/IP Timeout Fix for RDi/RDp and Client Access under Windows Vista and Windows 7

[UPDATES]

  1. [Spring 2012] I've modified the SetKeepAlive.exe program. It now uses a Setup.MSI installation routine and installs the required unicode DLL if it isn't already on your system.
  2. [Spring 2013] The app has been updated to accommodate IBM's Client Access v7 enhancements that better support keep alive. Even if you've already run SetKeepAlive.exe on your PCs, you should download, install and re-run setKeepAlive.

For the last few years I've been working remotely--away from the Power7 box that runs IBM i operating system. This website and my RPG IV development are all done using this remote system. To accomplish this remote work, I purchased a full license to IBM Rational Developer Platform for i, also (now) known as RDp and of course I use iSeries Access for Windows along with MochaSoft TN5250 to gain green screen access to the box.

The MochaSoft TN5250 software has a "Keep Alive" checkbox that tells the software to stay connected even when idle. I usually don't have trouble with that package. But mostly I launch IBM iSeries Access when I'm on Windows.

Both iSeries Access and RDp have been timing out--dropping the connection after a short idle period as I said, for the last couple of years. I had been use to loading up WDSc and/or SEU/PDM and leaving it up all day--often going away from my desk for hours. Upon my return everything would be working fine. But lately, if I turn away for more than what seems like 5 minutes, you can hear me swear in Italian.

Here's what happens: I launch RDp, load 2 or 3 source member and start editing. I save changes often because I'm afraid of loosing my connection. But then there are those lengthy edit sessions, where I write a new subprocedure and don't save for 10 to 15 minutes. Then when I press Save, I get the "Host System Disconnected" message. I can't save my work back to the system, I can't reconnect (why they don't make that an RDp option is still a question) so basically I've lost everything since my last save-to-the-host. There are things you can do to recover, like Edit/Copy/Paste into NotePad and then reverse the process--but is that really where we should be in 2011?

In my free time over the last few weeks I've been search for a solution and trying various suggestions. None have worked except the KeepAlive checkbox in the Mochasoft TN5250 program. Another suggestion that I had my hopes up, was in a forum post somewhere that indicated there was a .INI style entry in the iSeries Access .WS file. These are the files created by iSeries Access when you create a host connection configuration and save it. By adding "KeepAlive=Y" to that file, it is supposed to keep the session from disconnecting from the host. I thought, "Wow this is just a complex way to do exactly what I do in MochaSoft's TN5250 with a checkbox", but hey IBM was never accused of doing anything easy.  However, I never saw a change when I added the .WS file setting.

Early in the day on April 21, 2011, I decided to sit down and solve this problem. I opened my Microsoft Visual Studio 2010 IDE and created a new C++ project and began researching on the web. Here's what I found:

In the Windows Registry there is an entry for TCP/IP. This, as we all know, is the protocol used over the Internet, therefore it is the protocol used by iSeries Access and RDp to connect from the PC to the IBM i box. Starting with Windows Vista and continuing with Windows 7 (the version I use) the so called TCP/IP KeepAlive setting is not shipped in the default Windows installation. This is different from Windows 2000 and Windows XP, and if you do an UPGRADE install verses a clean install, you may have a different setting than the default, which is no keep alive timeout setting at all.

So basically all this swearing at IBM for lost connections was really an obscure Windows Registry setting that Microsoft provided with Windows 7. Of course IBM should have and could have put in an option to modify this setting, they didn't, but I am still apologizing to them for all the harsh words I used at my desk. Sorry. :)

UPDATE: This setting is also available in Windows XP, however (a) I never had a timeout issue on that OS, and (b) changing the setting seemed to have no impact under XP.

TCP/IP Registry Keep Alive Setting

The Registry key where the Keep Alive Time is stored, is as follows:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Tcpip\Parameters

The specific entry in that Registry key that needs to be added is:

 KeepAliveTime

The Keep Alive frequency is a DWORD (32-bit integer) value that is specified in milliseconds. A value of 5000 means a keep alive will be sent every 5 seconds. I have set up mine to send a keep alive every 20 seconds (KeepAliveTime=20000) on one machine, and 40.5 seconds (KeepAliveTime=40500) on another machine. I'm trying to determine the longest period I can go before loosing my connection.

Editing the Registry isn't enough. You also have to make a second adjustment--the .WS files created by iSeries Access must be modified. These two changes work together to keep the 5250 session from dropping, although if you do not use iSeries Access (you use Mochasoft's TN5250 instead) and you only used RDi/RDp then the second modification is not necessary and you're finished.

Modify the .WS INI File Setting

The other modification, as I mentioned earlier. is the .WS file that is created when you save a 5250 session configuration. The setting is in fact KeepAlive=Y and must appear in the Telnet5250 section of the .WS file. For example, if you create a session configuration named "MyiSeries.WS" that file is a text file in the .INI tradition, and can be opened in NotePad or another text editor and modified. Just insert the KeepAlive=Y entry into the [Telnet5250] section and save the file.

[Telnet5250]
KeepAlive=Y

You need to do BOTH MODIFICATIONS (update the Registry and change the .WS file) to prevent iSeries Access from timing out. RDp only requires the Registry entry modification.

 

SetKeepAlive Windows Tool

The typical way to change a Registry setting is to use RegEdit.exe from Microsoft (it is installed on every PC running Windows). But editing the Registry can be (A) difficult and (B) dangerous. If you're familiar with doing that, then have fun.

Editing a .WS file can be easy if you first open the NotePad.exe app and then from within NotePad open the .WS file. If you, however right-click on the .WS file and choose "Open with..." and select NotePad, you will actually change the .WS files so that they always open in Notepad and that just screws up things. An obscure checkbox appears when doing an "Open with..." that says "Always open this file type using this application" and it is checked by default, so be sure to UNCHECK that option before continuing.

For the rest of us, I've written a little Windows program named SetKeepAlive.exe that, when called, displays your current KeepAliveTime setting and allows you to change it. If there is no current setting for KeepAliveTime in the Registry, it creates the entry; it's up to you to specify the KeepAlive time setting, in millseconds (e.g., 10 seconds is specified as 10000). So when you run SetKeepAlive.exe and the KeepAlive timout value is zero, it means there was no existing setting for this entry in the Registry.

SetKeepAlive.exe also allows you to select a PC directory ("folder") where your .WS text files are stored. When you press Okay, not only is the Registry setting modified, but all .WS files that appear in the user-specified directory are updated to include the KeepAlive=Y entry in the Telnet5250 section. There is also a check-box to avoid having SetKeepAlive update the .WS files. 

Recently IBM has added and documented a new key alive section and entries in their .WS files for Client Access version 7.1. SetKeepAlive has been updated to insert these settings.Remember it is necessary to change both the .WS file and the Registry to end the disconnect issues with iSeries Access. Here is what the dialog box looks like for the SetKeepAlive.exe program.

[KEEPALIVE]
KeepAliveTimeOut=10
EnableTelnetKeepalive=Y
KeepAliveType=N

SetKeepAlive sets these entries for you. The KeepAliveTimeOut is in seconds instead of the Windows Registry Milliseconds value. SetKeepAlive converts the milliseconds you enter to seconds automatically.

When using SetKeepAlive, Windows might prompt you to confirm you want to run it, asking if you (A) trust the app and (B) want to run it as Administrator. You may get either, neither or both of these questions depending on your user profile classification.

SetKeepAlive Download

The program is SetKeepAlive.exe and is available in a ZIP file to midrangeNews.com members as a free download at this link.

There are two files in this ZIP package.

  1. The SETUP.EXE (don't run this program)
  2. The install script SetUp.MSI (run this script).

To install the SetKeepAlive program, double-click the SETUP.MSI file or right-click on it and select Install from the popup menu. After the install, you can run SetKeepAlive.exe from the Start/Program menu. After you've run it, YOU MUST REBOOT before the changes you have made will take effect. If you forget to reboot, you will not see a change in the way 5250 and RDi work until you reboot.

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: IBM i (AS/400) Client Access TCP/IP Timeout Problem and Fix
Posted: 3 years 3 months 13 days 15 hours 25 minutes ago
Edited: Thu, 18 Aug, 2011 at 12:14:46 (1193 days ago)

Remember, the SetKeepAlive.exe program runs on Windows Vista and 7 and sets up the Registry and .WS files to avoid timeout issues.

It does not do anything with firewall timeout issues or host system configurations that cause timeouts to occur.

Also, while SetKeepAlive does run under Windows XP and produces the changes to the Registry and .WS files, XP users report that they see no changes in timeout after using SetKeepAlive on Windows XP. At MidrangeNews.com we have not experienced a timeout issue under XP..

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: IBM i (AS/400) Client Access TCP/IP Timeout Problem and Fix
Posted: 3 years 2 months 19 days 20 hours 16 minutes ago
Edited: Fri, 17 May, 2013 at 10:16:44 (555 days ago)

There are settings on #IBMi that may also help:

  • WRKSYSVAL QINACTITV
  • CHGTCPA TCPKEEPALV
  • CHGTELNA TIMMRKTIMO