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

Add API to control IPEndPoint of HTTP request (like ServicePoint.BindIPEndPointDelegate) #20998

Closed
mstefarov opened this issue Apr 10, 2017 · 5 comments
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Net.Http
Milestone

Comments

@mstefarov
Copy link

I've got a few .NET services that run on machines with multiple IP addresses, and they need to occasionally send HTTP requests from specific IPs. Currently I use HttpWebRequest with a custom ServicePoint.BindIPEndPointDelegate and it works great. I'm hoping to port this service to .NET Core/Standard, but can't find any equivalent functionality in HttpClient/HttpClientHandler.

Is there any way to control local IP to which HttpClient/HttpClientHandler binds? Any workarounds or plans to add this functionality? This is the only thing holding back my porting efforts.

@davidsh
Copy link
Contributor

davidsh commented Apr 10, 2017

but can't find any equivalent functionality in HttpClient/HttpClientHandler.

There is no equivalent functionality in HttpClient/HttpClientHandler.

In addition, on .NET Core, the ServicePoint.BindIPEndPointDelegate does not function. That is because the HTTP stack on .NET Core uses a different architecture and is not possible to implement that functionality.

@mstefarov
Copy link
Author

mstefarov commented Apr 10, 2017

Hmm. I figured if System.Net.Sockets.Socket had a working cross-platform LocalEndPoint property, then perhaps it would be possible to implement the same for HttpClientHandler. If not, can you think of any workaround (e.g. setting up a proxy, a custom IHttpFilter, a custom HttpClientHandler, etc)? If not, please consider adding some extension points here in the future. There are several good use-cases for having multiple IPs on one machine.

@stephentoub
Copy link
Member

I figured if System.Net.Sockets.Socket had a working cross-platform LocalEndPoint property, then perhaps it would be possible to implement the same for HttpClientHandler.

Today HttpClient in .NET Core is not built on top of System.Net.Sockets; rather on Windows it's built on top of the native WinHttp and on Unix on top of the native libcurl. We are investigating having a managed implementation in the future that would be built on Sockets, at which point it's possible we could make this work, but that's not going to happen for 2.0.
cc: @geoffkizer

@karelz karelz changed the title How to control IPEndPoint of HTTP requests? Add API to control IPEndPoint of HTTP request (like ServicePoint.BindIPEndPointDelegate) May 19, 2018
@siberianguy
Copy link

Is there an update on this issue? We're stuck not being able to explicitly specify an ip address for a request

@stephentoub
Copy link
Member

Closing in favor of https://github.com/dotnet/corefx/issues/23426.

@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 3.0 milestone Jan 31, 2020
@dotnet dotnet locked as resolved and limited conversation to collaborators Dec 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-needs-work API needs work before it is approved, it is NOT ready for implementation area-System.Net.Http
Projects
None yet
Development

No branches or pull requests

5 participants