Set TCP keepalive idle time so idle connections survive NAT #502
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.48) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 555 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.378
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #502"
general
weight: 0.35
pacmano1
Replaces #501, which Mitch handed off. This is his commit with the review changes from #501 squashed in. He's still the author, and I'm listed as co-author.
Problem
TCP connections with keepalive enabled wait for the OS idle time before sending the first probe, typically 2 hours. Common NAT devices and load balancers drop idle connections much sooner (4 minutes for an Azure load balancer, 350 seconds for an AWS NAT gateway), and they do it silently. The next read on such a connection fails with errors like the
Connection timed outreported in #495.Change
TCP Listener and TCP Sender sockets can now get a shorter idle time wherever they already enable keepalive: when "Keep Connection Open" is on, and always for TCP Sender server mode. The new
oie.tcp.keepalive.idlesystem property sets the idle time in seconds and defaults to 120. It's documented inconf/custom.vmoptionsand in the "Keep Connection Open" tooltips on both connectors.When the TCP plugin starts with the server, it reads the OS idle time (
net.ipv4.tcp_keepalive_timeon Linux) from a new socket and decides once how keepalive sockets are handled:TCP_KEEPIDLEset to the property value.TCP_KEEPIDLEnot supported (such as Windows on a JDK without JDK-8308593): sockets are left alone.The decision isn't revisited until the engine restarts. If the OS value changes while the engine is running, sockets that get the property value keep getting it, even if the OS value drops below it. Sockets that are left alone use the OS value, so they follow the change, including a raise above the property value.
Logging:
All of this is logged at server startup, before any TCP connection, because
TcpServicePlugin.start()loadsSocketUtil.The failures are ERROR rather than WARN because the default
log4j2.propertiesonly shows ERROR for this logger, and either one means the configured idle time isn't in effect.Keepalive is still disabled explicitly when "Keep Connection Open" is off.
This is a system property rather than a mirth.properties setting because the TCP connector is a plugin. No plugin has its own key in mirth.properties, and reading one would mean adding TCP-specific code to
ConfigurationController.WebServiceDispatcherreadshttp.maxRedirectsthe same way.Behavior changes for release notes
-Doie.tcp.keepalive.idle=0tocustom.vmoptions.log4j2.propertiesdoesn't show. To see it in mirth.log and the Server Log, add a logger forSocketUtiltoconf/log4j2.properties:An invalid
oie.tcp.keepalive.idlevalue is logged at ERROR and shows without this.Connection timed outafter about 13 minutes instead of about 2h11m. The diagnostic in #495 for telling idle drops (about 2h11m) from undelivered ACKs (about 15 minutes) by timing no longer works once this is in.Relationship to #495
This addresses the most likely cause of the idle-connection drops in #495, but it doesn't change how
TcpReceiverlogs read errors, which is what #495 asks for. So the issue should stay open.---
🤖 Drafted with Claude Code