SMOODEV-2513: add bounded connect timeout to .NET SmooAI.Fetch#91
Open
brentrager wants to merge 1 commit into
Open
SMOODEV-2513: add bounded connect timeout to .NET SmooAI.Fetch#91brentrager wants to merge 1 commit into
brentrager wants to merge 1 commit into
Conversation
…y with #88) Mirror the Rust connect-timeout port. api-prime stalls (SMOODEV-2481) trace to fresh SYNs black-holing to dead pod IPs still in a ClusterIP's iptables; without a connect timeout the client waits the whole-request timeout before a retry can land on a live endpoint. - SmooFetchOptions.ConnectTimeout (TimeSpan?), default null -> unchanged. - SmooFetchBuilder.WithConnectTimeout, mirrors WithTimeout. - Self-managed client uses SocketsHttpHandler; sets ConnectTimeout only when set. - IHttpClientFactory-managed clients: caveat documented (factory owns handler). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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.
Problem
Parity with Rust PR #88 (SMOODEV-2498). api-prime's ~16s API stalls (SMOODEV-2481) traced to fresh SYNs black-holing to dead pod IPs still lingering in a ClusterIP's iptables during an endpoint-removal race. With no connect timeout, the client waits the full whole-request timeout before the existing retry can land on a live pod.
Fix
Add a bounded connect timeout so a black-holed connect fails in ~the configured window and the existing retry lands on a live endpoint, while slow-but-alive handlers (governed by the whole-request timeout) are untouched.
SmooFetchBuilder.WithConnectTimeout(TimeSpan)— mirrorsWithTimeout.SmooFetchOptions.ConnectTimeout: TimeSpan?— defaultnull, so existing consumers are behaviorally unchanged.Create(...)path now builds aSocketsHttpHandlerand setshandler.ConnectTimeoutonly when the option is set (unset → handler default = Infinite, byte-identical to before).IHttpClientFactory caveat
ConnectTimeoutis only applied on the SDK-owned handler (Create). ForRequireHttpClientFactory/ DI-managed clients the factory owns the handler, so the connect timeout must be configured at registration, e.g..ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler { ConnectTimeout = ... }). Documented inline inCreateFromFactory.Test
ConnectTimeoutTests.cs: a connect to a non-routable black-hole IP (10.255.255.1:80) with a 500msConnectTimeoutand a 5s whole-request timeout throws in ~0.5s (asserted< 3s) instead of hanging to the whole timeout. Full suite green (dotnet test: 32 passed),dotnet format --verify-no-changesclean.🤖 Generated with Claude Code