You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In .Net Core 2.2 and up the SocketsHttpHandler is the preferred HttpHandler to use when configuring channel options HttpHandler. In fact, .Net 6 documentation always show SocketsHttpHandler as examples in performance best-practices such as setting EnableMultipleHttp2Connections for connection concurrency.
However, what confuses me is if the fact that HttpClientHandler just uses SocketsHttpHandler behind the scenes as seen in this code.
If HttpClientHandler just uses SocketsHttpHandler, is the code below that sets a.HttpHandler = new HttpClientHandler just the same as a.HttpHandler = new SocketsHttpHandler?
services.AddCodeFirstGrpcClient<IService>(
config =>
{
config.Address = //URI;
config.ChannelOptionsActions.Add(
a =>
{
a.HttpHandler = new HttpClientHandler
{
// Do some setup
};
});
});
Since HttpClientHandler just uses SocketsHttpHandler behind the scenes, is there a way to set EnableMultipleHttp2Connections when using just HttpClientHandler just like in the code above?
The text was updated successfully, but these errors were encountered:
Since HttpClientHandler just uses SocketsHttpHandler behind the scenes, is there a way to set EnableMultipleHttp2Connections when using just HttpClientHandler just like in the code above?
No, there isn't. That's a reason why to prefer SocketsHttpHandler where possible.
@JamesNK thanks for confirming. I understand now that SocketsHttpHandler is still preferred on cases where we need to set EnableMultipleHttp2Connections. I assume the answer to question 1 is also yes. Meaning a.HttpHandler = new HttpClientHandler is equivalent to a.HttpHandler = new SocketsHttpHandler.
In .Net Core 2.2 and up the SocketsHttpHandler is the preferred HttpHandler to use when configuring channel options HttpHandler. In fact, .Net 6 documentation always show
SocketsHttpHandler
as examples in performance best-practices such as settingEnableMultipleHttp2Connections
for connection concurrency.However, what confuses me is if the fact that
HttpClientHandler
just usesSocketsHttpHandler
behind the scenes as seen in this code.HttpClientHandler
just usesSocketsHttpHandler
, is the code below that setsa.HttpHandler = new HttpClientHandler
just the same asa.HttpHandler = new SocketsHttpHandler
?HttpClientHandler
just usesSocketsHttpHandler
behind the scenes, is there a way to setEnableMultipleHttp2Connections
when using justHttpClientHandler
just like in the code above?The text was updated successfully, but these errors were encountered: