fix(grpc): configure Kestrel HTTP/2 keepalive (60 s ping, 10 s timeout) under MxGateway:Protocol (SES-005, #253)

This commit is contained in:
Joseph Doherty
2026-12-03 10:03:53 -05:00
parent 87b8f8da09
commit a474d3219b
8 changed files with 259 additions and 4 deletions
+8 -2
View File
@@ -75,7 +75,9 @@ paths, timeouts, queue sizes, enum values, or protocol values are invalid.
},
"Protocol": {
"WorkerProtocolVersion": 1,
"MaxGrpcMessageBytes": 16777216
"MaxGrpcMessageBytes": 16777216,
"Http2KeepAlivePingDelaySeconds": 60,
"Http2KeepAlivePingTimeoutSeconds": 10
},
"Galaxy": {
"ConnectionString": "Server=localhost;Database=ZB;Integrated Security=True;TrustServerCertificate=True;Encrypt=False;",
@@ -440,8 +442,12 @@ is **not yet available**.
|--------|---------|-------------|
| `MxGateway:Protocol:WorkerProtocolVersion` | `1` | Worker IPC protocol version expected by the gateway and worker. This must match `GatewayContractInfo.WorkerProtocolVersion`. |
| `MxGateway:Protocol:MaxGrpcMessageBytes` | `16777216` | Public gRPC max send and receive message size in bytes. The same default is used by official clients. The validator allows values from `1024` through `268435456`, and requires `MxGateway:Worker:MaxMessageBytes` to exceed this by at least the 64 KiB worker-frame envelope reserve and by no more than twice that reserve, so a `DrainEvents` reply budgeted at the pipe maximum still fits this send cap (see the Worker options). |
| `MxGateway:Protocol:Http2KeepAlivePingDelaySeconds` | `60` | Seconds an HTTP/2 connection may go without receiving a frame before the gateway sends a keepalive PING (Kestrel `Limits.Http2.KeepAlivePingDelay`). `0` turns server pings off. Must be between `0` and `86400`. Without server pings, a client that vanished without closing its connection (power loss, a firewall or NAT idle drop) keeps its `StreamEvents` call open on a quiet session indefinitely: the session's subscriber slot stays taken, so the client's own resume is refused with `ResourceExhausted` (`EventSubscriberAlreadyActive`), and the session and its x86 worker are never swept. With pings, the dead peer is detected within the delay plus the timeout and the subscriber detaches. |
| `MxGateway:Protocol:Http2KeepAlivePingTimeoutSeconds` | `10` | Seconds the gateway waits for any frame after a keepalive PING before it closes the connection (Kestrel `Limits.Http2.KeepAlivePingTimeout`). Must be between `1` and `3600`. |
The protocol option is exposed for diagnostics and explicit deployment
Client keepalive pings need no server setting. Kestrel has no minimum client-ping interval (unlike grpc-core and grpc-go servers, it never answers frequent pings with `GOAWAY`/`ENHANCE_YOUR_CALM`), it answers pings with or without an active call, and a received ping resets the connection's idle keep-alive timeout. The official clients ping every 30 s with a 10 s timeout, also while no call is active, which keeps an idle connection open and detects a dead gateway from the client side.
The worker protocol version option is exposed for diagnostics and explicit deployment
configuration, not for compatibility negotiation. A mismatch fails validation
at startup.