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.
The Registry key where the Keep Alive Time is stored, is as follows:
The specific entry in that Registry key that needs to be added is:
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.
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.
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.
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.
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.
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.