Repository navigation
YARP direct forwarding: document service discovery with a custom HttpMessageInvoker - #38229
Open
assemkhashaba404 wants to merge 1 commit into
Open
assemkhashaba404 wants to merge 1 commit into
assemkhashaba404 wants to merge 1 commit into
Conversation
Author
|
@dotnet-policy-service agree |
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.
Contributes to dotnet/yarp#2838
What
Adds a short subsection, "Service discovery and a custom HTTP client", to the YARP direct forwarding article.
Why
dotnet/yarp#2838 reports that
MapForwarderresolves Aspire/service-discovery names such ashttps://apiby default, but fails with "No such host" once a customHttpMessageInvokeris passed in. The article doesn't mention this.The cause:
AddHttpForwarderWithServiceDiscoveryregisters a service-discovery-awareIForwarderHttpClientFactory, and a customHttpMessageInvokerbypasses it. The new text says that, and shows how to keep service discovery by wrapping the inner handler withIServiceDiscoveryHttpMessageHandlerFactory.CreateHandler(...).How it was checked
I reproduced all three cases with a small local app (.NET 8 SDK, Yarp.ReverseProxy 2.3.0, Microsoft.Extensions.ServiceDiscovery and Microsoft.Extensions.ServiceDiscovery.Yarp 11.0.1, "api" resolved from configuration):
MapForwarderwithAddHttpForwarderWithServiceDiscovery: request succeedsHttpMessageInvoker(new SocketsHttpHandler{...}): 502, "Name or service not known (api:80)"IServiceDiscoveryHttpMessageHandlerFactory.CreateHandler(...): request succeedsThe repro used
http://apiandAllowAutoRedirect = true. The sample in the article useshttps://apiandAllowAutoRedirect = false, so it was not run exactly as written, though the mechanism is the same. I did not run the docs build.AI disclosure
This change was written by an AI assistant (Instinct) working for the PR author, and verified with the local repro above. The article already carries
ai-usage: ai-assisted. I did not changems.date; happy to update it if reviewers want.Internal previews
Build report