SyliusResourceBundle icon indicating copy to clipboard operation
SyliusResourceBundle copied to clipboard

Unix domain socket support

Open igrishaev opened this issue 6 years ago • 7 comments

Are there any plans on adding interaction with Unix domain sockets?

What I'd like to achieve is to interact with Docker daemon via socket as follows:

curl --unix-socket /var/run/docker.sock http:/v1.24/images/json

As I see it, there should be a separate unix.clj module that provides client and handler functions.

I found a small Java example which I'm going to port to Clojure using existing Aleph abstractions. I'm new to Netty so could you at least give me a tip whether that's a good example or not?

igrishaev avatar Jan 23 '19 20:01 igrishaev

@igrishaev Let me put "feature request" tag on this. There are no specific plans, but I've been thinking about extending a list of supported transports for a while.

kachayev avatar Jan 23 '19 21:01 kachayev

And.. yeah, there's an issue already for this :) https://github.com/ztellman/aleph/issues/212

kachayev avatar Jan 23 '19 21:01 kachayev

I've managed to get HTTP client to work through the socket with epoll transport here. There's still one thing that bothers me a lot...

(def options {:connections-options {:unix-socket "/var/run/docker.sock"}})
(def through-socket (http/connection-pool options))
(http/get "/images/json" {:pool through-socket})

This is a valid request, although it would fail. Because here we would still try to parse a java.net.URL. Meaning I have to do something like

(def options {:connections-options {:unix-socket "/var/run/docker.sock"}})
(def through-socket (http/connection-pool options))
(http/get "http://this-is-dummy-host/images/json" {:pool through-socket})

That's the same problem cURL has: it still requires you to put a valid URL with scheme and hostname even if you've specified --unix-socket option. @ztellman are we okay with the latest or should we dig deeper to find a better solution?

I also do a substitution of the remote-address to DomainSocketAddress when creating the connection, which obviously causes trouble to SSL configuration: with the current implemention we need to carry host/port (when given) separately from remote-address. Which is doable, it just makes the code less readable with quite a few new if-else branches here and there. So I'm still looking for a better approach.

kachayev avatar Feb 01 '19 22:02 kachayev

should either of these work in current versions ?

olymk2 avatar Nov 09 '19 12:11 olymk2

@kachayev @igrishaev @ztellman what's the status of this pr https://github.com/ztellman/aleph/compare/master...kachayev:ft-unix-socket?expand=1

are we likely to see it merged / what's blocking it ?

olymk2 avatar Nov 20 '19 08:11 olymk2

Was this solved with the merged https://github.com/clj-commons/aleph/pull/480 ? Looks like it just needs documentation now?

tom-adsfund avatar Feb 11 '21 19:02 tom-adsfund

Was this solved with the merged #480 ? Looks like it just needs documentation now?

Nope, the respective changes for unix domain sockets support were reverted before merge. See https://github.com/clj-commons/aleph/pull/480#issuecomment-672580079 and https://github.com/clj-commons/aleph/pull/480/commits/a9736bf98e1d94d089af20a51677531318392ade

DerGuteMoritz avatar Apr 09 '21 16:04 DerGuteMoritz