Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host Parameter Not Used in HttpClientCallInvoker? #1158

Closed
thefringeninja opened this issue Dec 31, 2020 · 2 comments
Closed

Host Parameter Not Used in HttpClientCallInvoker? #1158

thefringeninja opened this issue Dec 31, 2020 · 2 comments
Labels
question Further information is requested

Comments

@thefringeninja
Copy link
Contributor

In our server cluster setup, we need to dynamically select an endpoint based on the cluster information. This is pretty easy with Grpc.Net - throw in a custom HttpMessageHandler to modify the request message before it goes out.

Now for the wrinkle: The performance characteristics of HttpClient have improved dramatically for net5.0. But they are not there for net48 or netcoreapp3.1, so in that case we want to leverage the older c-based grpc bits. This means that the netstandard2.1 implementation is off the table.

I see that Interceptors let you change the host(at least I assume so, can't find any docs on this). However I see that in HttpClientCallInvoker that parameter is being ignored: https://github.com/grpc/grpc-dotnet/blob/8283efe58eb2cefc3635641e43410611ac13b436/src/Grpc.Net.Client/Internal/HttpClientCallInvoker.cs#L98|

If possible I would prefer to have the host selection logic in one place, so my questions are:

@JamesNK
Copy link
Member

JamesNK commented Jan 7, 2021

Does the c library respect this parameter?

I tested what happens and Grpc.Core only uses that parameter to change the request hostname header. It doesn't change the address or port that the request is sent to.

If so would you accept a PR to align the implementations?

HttpClient doesn't allow that header to be changed. HttpClient sets it for you based on the destination address.

Or is there another way to do this that works across all platforms?

I don't know. I'm not a Grpc.Core expert. Perhaps you should ask at grpc/grpc?

@thefringeninja
Copy link
Contributor Author

thefringeninja commented Jan 7, 2021

HttpClient doesn't allow that header to be changed. HttpClient sets it for you based on the destination address.

We have in the past used a custom HttpMessageHandler to override the destination address. However we have found a better way to do what we want - have one channel per address. Thanks anyway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants