Keeping 5250 Alive
June 11, 2008 Tom Van Looy
Some time ago, we had problems with Client Access sessions being reset. It seemed that these connections were traveling over a VPN that got disconnected after being idle for a while. Because we were not in charge of the VPN, I used TCP keepalive as a workaround for this problem.
A TCP connection can set the SO_KEEPALIVE option with the setsockopts() system call. When the TCP connection is idle for a specified period of time, a keepalive packet will be sent to keep the connection open. (In practice, this keepalive packet is a request for acknowledgement of the previous packet.) Most programming languages provide a library routine to activate the keepalive option. For example, Java provides the setKeepAlive() method, which can be invoked after socket construction.
There are three parameters that can be configured for keepalive messages. On a Windows machine, these are registry values in HKLMSYSTEMCurrentControlSetServicesTcpIpParameters. KeepAliveInterval (default 1 second), KeepAliveTime (default 2 hours) and TcpMaxDataRetransmission (default 5 seconds). On a Linux machine these are sysctl values in net.ipv4 (or procfs in /proc/sys/net/ipv4), tcp_keepalive_intvl (default 75s), tcp_keepalive_time (default 2h), and tcp_keepalive_probes (default 9).
TCP keepalive messages are described in RFC1122. The RFC also points out some disadvantages of sending keepalive messages.
It is possible to activate keepalive messages on the 5250 emulator. The startup file for a System i connection (.WS file) must be edited with a text editor. These files reside by default in C:Program FilesIBMClient AccessEmulatorPrivate. Below the [Telnet5250] option you add the option KeepAlive=Y. This is enough to activate keepalive messages on a 5250 session.
The IBM Client Access suite delivers a command line tool, CWBCOPWR, that can configure some of the keepalive parameters. For example, to set KeepAliveTime to 10 seconds and KeepAliveInterval to 1 second, use the command “cwbcopwr/MKA:1,10”.
Tom Van Looy started out his IT career as an ILE/RPG developer in 2005 and moved over to the position of i5/OS system engineer in 2007. He is currently employed by Lisis nv in Belgium. Although a Unix enthusiast, he also has great affinity with GNU/Linux and *BSD. Tom can be reached by email at email@example.com.