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

[Question] HttpClientHandler, SocketsHttpHandler for a .NET Core 3.1 app #35212

Closed
dgkanatsios opened this issue Apr 20, 2020 · 3 comments
Closed
Labels
area-System.Net.Http question Answer questions and provide assistance, not an issue with source code or documentation.
Milestone

Comments

@dgkanatsios
Copy link

We have a .NET Core 3.1 app that we're using HttpClient to connect to a web server. The HttpClient instance is constructed via a HttpClientHandler instance we are creating.

From what I understand reading this, in >=2.1 the HttpClientHandler was rewritten to use SocketsHttpHandler.
Still, this page seems to recommend SocketsHttpHandler.

Can you clarify on what's the optimal solution? FWIW, we don't need the older HTTP stacks.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net.Http untriaged New issue has not been triaged by the area owner labels Apr 20, 2020
@ghost
Copy link

ghost commented Apr 20, 2020

Tagging subscribers to this area: @dotnet/ncl
Notify danmosemsft if you want to be subscribed.

@dgkanatsios dgkanatsios changed the title HttpClientHandler, SocketsHttpHandler for a .NET Core 3.1 app [Question] HttpClientHandler, SocketsHttpHandler for a .NET Core 3.1 app Apr 20, 2020
@stephentoub
Copy link
Member

From what I understand reading this, in >=2.1 the HttpClientHandler was rewritten to use SocketsHttpHandler.

Correct.

Still, this page seems to recommend SocketsHttpHandler.

In 3.1, there are actually two implementations behind HttpClientHandler: SocketsHttpHandler, and then as a fallback an OS-specific handler. That page is really just saying that SocketsHttpHandler is the default implementation, but you can opt-out to the fallback if necessary.

Can you clarify on what's the optimal solution? FWIW, we don't need the older HTTP stacks.

Using HttpClientHandler is totally fine, using SocketsHttpHandler as an implementation. If you want access to additional knobs and configuration exposed via properties on SocketsHttpHandler, you can construct it directly.

@stephentoub stephentoub added question Answer questions and provide assistance, not an issue with source code or documentation. and removed untriaged New issue has not been triaged by the area owner labels Apr 20, 2020
@dgkanatsios
Copy link
Author

thanks @stephentoub for the ultra fast response!

@karelz karelz added this to the 5.0.0 milestone Aug 18, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Net.Http question Answer questions and provide assistance, not an issue with source code or documentation.
Projects
None yet
Development

No branches or pull requests

4 participants