-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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 Unix Sockets #16339
Comments
Thanks, @markrendle. This is interesting. @davidsh, what's the purpose of |
It was intended as an arbitrary dictionary of name/value pairs for developers to pass to their own custom handlers. We have not, to date, embraced using it as a mechanism to control our own main handers such as HttpClientHandler, WinHttpHandler, CurlHandler. Once we do that, we will need to support it for a long time. If we go down this route, we will want to come up with a useuful and unique mechanism to identity properties that these specific handlers might care about vs. other name/value pairs that a developer wants to use for custom handlers that they write. cc: @CIPop @SidharthNabar |
There's some discussion on this on the cURL mailing list.
It's pretty nasty though. Here's another nasty idea:
@markrendle couldn't you implement a custom handler that does the business (perhaps calling out to cURL)? |
@friism I have thought about that, and of course there's a very nice MIT-licensed CurlHandler that I could just copy and add a couple of lines to... 😎 |
@SidharthNabar, can you comment on this? With CurlHandler not exposed publically, we're limited in options, and this seems like a reasonable one, i.e. using HttpRequestMessage.Properties to pass additional info into the handler, namely a string to pass to libcurl's CURLOPT_UNIX_SOCKET_PATH option. If in the future we do expose CurlHandler, then we'd also expose this as a property, and the implementation would fall back to continuing to check Properties for compatibility. |
@stephentoub @markrendle - This is indeed an interesting idea to get developers unblocked. Here are the issues we need to worry about:
Thanks, |
Thanks, @SidharthNabar.
Yes, this particular property only makes sense on Unix.
I don't think we can simply stop supporting it, but as I alluded to, I think we'd expose a property, we'd check that property first, and then if that property wasn't set we'd fall back to checking the properties bag purely for compat purposes.
The actual underlying option on libcurl is specified per request as well, as is true for pretty much every other option exposed on the handler. We configure every request individually based on the values on the handler.
Yes. That is of course the other option: we could simply expose CurlHandler publically now. |
@markrendle I'm working on finishing a fully managed HttpClientHandler that will be able to talk to any stream, including Unix domain sockets, Windows named pipes, and of course TCP, a la Go. This is based on some work started by the aspnet team and abandoned. I am doing this specifically to talk to the Docker daemon running on Linux or Windows. I'm also planning on supporting the connection hijacking stuff that's necessary for Docker attach -- I don't think libcurl can support this, but I'm not sure yet. I've been planning on incorporating it into https://github.com/ahmetalpbalkan/Docker.DotNet, but we could put it elsewhere once it has stabilized (or even sooner if there is a lot of demand). I suspect the right long-term thing is to move this functionality into corefx. CoreCLR is currently getting a lot of benefit from wrapping existing platform libraries, but it's a shame to be limited to Windows and Curl levels of functionality in the long run. It's really cool what you can do in Go when everything is written to standard interfaces and can be plugged together in interesting ways. My two cents, I think it would be unwise to expose CurlHandler functionality from corefx since that will make it harder to eliminate this dependency in the future. cc/@swernli, @ahmetalpbalkan, @jterry75 FYI |
@ahmetalpbalkan That's brilliant. The main reason I wanted the I agree that fully managed libraries like that are the way to go (no pun I'll happily contribute to your existing Docker project, and if you elect On Fri, 8 Apr 2016, 19:33 John Starks, notifications@github.com wrote:
|
@jstarks Sorry, I misaddressed that reply because I was on my phone in the queue for Goofy's Barnstormer. Is your managed HttpClientHandler anywhere I could access it? |
@stephentoub wrote:
and @markrendle nodded enthusiastically. "Yes," he wrote, "you definitely could do that." 😀 |
Any update/workaround for this? |
For .NET Core 2.1 we've switched away from using libcurl and are now using a managed implementation. We have not added unix domain socket support to it, and there are currently no plans to do so. |
Triage: Per @stephentoub it seems to be irrelevant now (we are deleting libcurl from .NET Core). |
Relates to SocketsHttpHandler should support custom Dialers. |
Yes. There are two things here:
|
This has been resolved via the API added here in .NET 5: #41949 |
I previously opened #15159 asking about exposing Unix Socket functionality in the CurlHandler, and @stephentoub closed the issue with an excellent explanation.
However, as things in .NET Core Land have progressed, I'm wondering again about this.
Basically, the dotnet/corert project is looking to enable native compilation, which means that C# can potentially be used to create useful, native cross-platform tools, much like Go.
It's very common for these command-line applications or services on Linux to need to communicate over Unix Sockets; for example,
/var/run/docker.sock
is used to talk to the local Docker daemon.I had a quick look at the
HttpClient
andHttpRequestMessage
APIs, and the internal handling ofHttpRequestMessage
byCurlHandler
.There is a potential opportunity to introduce this functionality in an obscure but workable way without breaking or even changing the public API, by using the
Properties
dictionary onHttpRequestMessage
(which is aDictionary<string, object>
). One could set a property in here, perhaps like:CurlHandler
could then check for this property and setCURLOPT_UNIX_SOCKET_PATH
usingInterop.Http.EasySetOptionString
.An application or library developer using this feature could easily create extension methods on
HttpClient
to give themselves a nicer syntax.If that API would be acceptable, I'd be happy to have a go at implementing it.
Thoughts?
The text was updated successfully, but these errors were encountered: