In an open connection, if a client is not requesting data from the server then the NCache client automatically closes the connection for better security and resource management. In order to avoid this closure, the
keep-alive property in NCache ensures that the connection stays open, when
keep-alive is enabled and can also configure the interval for which it stays open.
This feature can be enabled via manually editing the client.ncconf file and is disabled by default. Alternatively, you can also employ the
CacheConnectionOptions API, by setting
EnableKeepAlive to true and establishing a
enable-keep-alive property specifies whether the connection between the client and server should be kept "alive", i.e., if the client is not communicating with its connected servers,
enable-keep-alive property sends heartbeats or pings from the client to server nodes at fixed intervals. This feature is particularly useful if there is a firewall which breaks idle network connections or if it detects connection breakages proactively.
<ncache-server connection-retries="3" ... enable-keep-alive="true" keep-alive-interval="30" />
The default value of
connection-retries is 3, though you can change it as you feel appropriate. You can read more about connection retries, here.
keep-alive-interval is the interval, in seconds, after which a heartbeat is sent from the idle client to server to sustain the connection. The interval ranges between 1 and 7200 seconds with default set at 30 seconds. If any value is specified out of the range, NCache resorts to using the default value.