mbproxy: add keepalive / connection monitoring
The DL205/DL260 ECOM emits no TCP keepalives, so an idle backend socket can be silently dropped by a middlebox (switch, firewall, NAT) after 2-5 minutes. Enable OS SO_KEEPALIVE on backend and accepted upstream sockets, and drive a periodic synthetic FC03 heartbeat on each idle backend socket so a dead path is detected before a real client request hits it. Controlled by Connection.Keepalive (ON by default). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -141,6 +141,27 @@ internal static class ReloadValidator
|
||||
errs.Add(
|
||||
$"Connection.GracefulShutdownTimeoutMs must be > 0; got {next.Connection.GracefulShutdownTimeoutMs}.");
|
||||
|
||||
// ── 6. Keepalive section ──────────────────────────────────────────────
|
||||
// Schema bounds are also checked in MbproxyOptionsValidator; re-checking here keeps
|
||||
// the hot-reload gate self-contained. The cross-field rule (heartbeat interval must
|
||||
// sit above the request timeout, or it would fire continuously) lives only here.
|
||||
var ka = next.Connection.Keepalive;
|
||||
if (ka.TcpIdleTimeMs <= 0)
|
||||
errs.Add($"Connection.Keepalive.TcpIdleTimeMs must be > 0; got {ka.TcpIdleTimeMs}.");
|
||||
if (ka.TcpProbeIntervalMs <= 0)
|
||||
errs.Add($"Connection.Keepalive.TcpProbeIntervalMs must be > 0; got {ka.TcpProbeIntervalMs}.");
|
||||
if (ka.TcpProbeCount <= 0)
|
||||
errs.Add($"Connection.Keepalive.TcpProbeCount must be > 0; got {ka.TcpProbeCount}.");
|
||||
if (ka.BackendHeartbeatProbeAddress is < 0 or > 65535)
|
||||
errs.Add(
|
||||
$"Connection.Keepalive.BackendHeartbeatProbeAddress must be in [0, 65535]; " +
|
||||
$"got {ka.BackendHeartbeatProbeAddress}.");
|
||||
if (ka.BackendHeartbeatIdleMs <= next.Connection.BackendRequestTimeoutMs)
|
||||
errs.Add(
|
||||
$"Connection.Keepalive.BackendHeartbeatIdleMs ({ka.BackendHeartbeatIdleMs}) must be greater " +
|
||||
$"than Connection.BackendRequestTimeoutMs ({next.Connection.BackendRequestTimeoutMs}); " +
|
||||
"a heartbeat interval at or below the request timeout would fire continuously.");
|
||||
|
||||
errors = errs;
|
||||
return errs.Count == 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user