servers.keepalive
keepalive
The keepalive block configures operating system TCP keepalive probes. TCP keepalive detects
connections whose peer disappeared without closing them, such as a crashed host or a flow that a
firewall or NAT device dropped. It also keeps idle connections open through devices that remove
idle flows. The same block is used by listeners and by outbound backend connections, such as
RADIUS backend connections and the
Netlogon backend.
keepalive {
idle 60s;
interval 10s;
count 3;
}
| Parameter | Description | Accepted values |
|---|---|---|
idle | Time without any traffic before the first probe is sent | Whole seconds from 1s to 32767s |
interval | Time to wait for an answer before sending the next probe | Whole seconds from 1s to 32767s |
count | Number of unanswered probes in a row before the connection is closed | 1 to 127 |
These are the ranges that Linux accepts. A value outside them, or a duration with a fraction of a second, is a configuration error.
Set all three parameters in every keepalive block. Without the block, TCP keepalive is disabled,
unless the configuration item documents its own defaults, such as the
Netlogon backend.
How the probes work
Probes are sent only on a connection that has been idle for idle. Any received or sent data,
including the answer to a probe, restarts the idle time, so a busy connection is never probed.
- While traffic flows, no probes are sent.
- After
idlewithout traffic, one probe is sent. - If the peer answers, the connection is idle again, and the next probe follows after another
idleperiod. A healthy idle connection is therefore probed once everyidle. - If the peer does not answer, another probe follows after
interval. Probes continue everyintervalwhile they stay unanswered. - After
countunanswered probes in a row, the operating system closes the connection.
A peer that disappears is detected at most idle + count * interval after the last traffic.
With the example above, that is 60s + 3 * 10s = 90s.