feat: add connection pooling and transient error handling for stale HTTP connections (FME-14487)#336
Open
sanzmauro wants to merge 1 commit intodevelopmentfrom
Open
Conversation
…TTP connections (FME-14487) Use SocketsHttpHandler on .NET 5+ with PooledConnectionLifetime (10min) and PooledConnectionIdleTimeout (30s) to prevent stale keep-alive connections causing "response ended prematurely" errors on POST requests. Also catch transient HttpRequestException/IOException as a warning instead of error. Includes integration tests with a PrematureCloseServer to reproduce and verify the stale connection scenarios.
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.
.NET SDK
What did you accomplish?
SocketsHttpHandleron .NET 5+ withPooledConnectionLifetime(10 min) andPooledConnectionIdleTimeout(30s) to recycle connections before server-side keep-alive timeouts close them.HttpIOException) errors on POST requests caused by stale keep-alive connections. .NET does NOT auto-retry POST requests (non-idempotent) on connection failures, unlike GET requests.HttpRequestExceptionwithIOExceptioninner exception and log as warning instead of error, allowing retry logic to recover gracefully.How to test new changes?
dotnet test tests/Splitio.Integration-events-tests/ --filter TestCategory=IntegrationExtra Notes
SocketsHttpHandlerconfiguration is gated behind#if NET5_0_OR_GREATER— older .NET Framework targets continue usingHttpClientHandler.PrematureCloseServer(raw TCP) is used in tests since WireMock doesn't support simulating mid-connection closures.