Make NLB listener TCP idle timeout configurable and set 1800s for prod HTTPS - #261
Merged
Merged
Conversation
…800s for prod HTTPS
ryanjjung
approved these changes
Sep 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed?
Adds an optional
tcp_idle_timeout_secondssetting (service name → seconds, 60–6000) topublic_load_balancerandprivate_load_balancers, passed to each service'saws.lb.Listener. Services not listed keep the AWS default of 350 s. Prod setshttps: 1800.Code and description were written by an AI agent (Cursor) at my direction.
Why?
An NLB stops tracking a TCP flow once it has been idle for the listener's idle timeout (350 s by default), without sending FIN or RST to either side. If the client closes the connection after that point, the NLB drops the client's FIN/RST and the target never receives it.
Stalwart does not close idle HTTP connections itself: its HTTP server has no idle/header read timeout and it does not enable
SO_KEEPALIVEon accepted sockets. A connection whose close is dropped therefore staysESTABLISHEDon the node indefinitely and keeps one of the HTTPS listener's concurrent connection slots (8192 by default). When all slots are held, Stalwart refuses new HTTPS connections.Clients that hold idle connections longer than 350 s before closing trigger this on every such connection; for example, Cloudflare closes idle origin connections after 900 s (docs). With an 1800 s idle timeout the NLB still tracks the flow when these clients close, so the close reaches Stalwart and the socket is released.
Limitations and Notes
pulumi preview --stack prodshowstcpIdleTimeoutSeconds: 350 => 1800onmailstrom-prod-pub-listener-https(from stored state) and no other change from this PR.Applicable Issues
None.