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 support for Unix-domain sockets #864

Open
fpagliughi opened this issue Apr 27, 2020 · 6 comments
Open

Add support for Unix-domain sockets #864

fpagliughi opened this issue Apr 27, 2020 · 6 comments
Milestone

Comments

@fpagliughi
Copy link
Contributor

I'd like to add support for Unix-domain sockets.

These satisfy the MQTT v5 transport requirement for "ordered, lossless, [bidirectional] stream of bytes", but on a local machine, they provide higher throughput with lower latency and increased security in comparison to TCP.

A great use case for MQTT is providing an internal message bus on a remote device or computer, in which a large percentage of the messages are simply passed around inside the local machine. The use of MQTT for this is particularly helpful in IoT gateways where some subset of the messages are then bridged to a cloud server in a more traditional MQTT usage. But using UNIX sockets for the internal communications would make them faster and safer.

I have long rallied for this feature to be added to Mosquitto based on the performance metrics, to no avail. But Roger finally relented based on the security argument:

The main reason that I changed my mind on this was the idea of having localhost only listener, where the access control was through the socket permissions. It's much easier to isolate a trusted listener that way.
eclipse/mosquitto#467

I would suggest for the Paho Client(s) we use a URL in the form:

unix://path/to/socket

whereas if it's an absolute path, use the additional slash:

unix:///absolute/path/to/socket

And my biggest hope is that this is actually pretty trivial to implement in the client. Once opened, a Unix socket should mostly just behave as a socket.

@icraggs
Copy link
Contributor

icraggs commented Apr 27, 2020

I thought about this a long time ago, and I seem to remember implementing at least a trial. I think, one of the reasons that it hasn't been done so far is that it isn't quite as straightforward as one would hope. I would be happy to be proved wrong in that, but I wouldn't be surprised either way.

When you say "I'd like to add" ... does that mean you are considering a PR? :-)

@fpagliughi
Copy link
Contributor Author

You might have noticed my "once opened" caveat. Sometimes permissions and security issues trip you up to make a connection, but they're usually well behaved once running. But I was throwing this out to see if anyone could think of any other problems.

And I suppose that I am "considering" a PR. But I have a release of the Rust library to push out this week, then the C++ service release, and then a bigger update on the Rust lib to get it up to "modern" Rust standards.

So if anyone beat me to this, I wouldn't be (a) surprised, or (b) offended.

@icraggs icraggs added this to the Backlog milestone Oct 21, 2020
@pulquero
Copy link

Came across this for the python client https://pypi.org/project/paho-socket/. Might be a stop-gap for some of us while we are waiting on this issue.

@vjardinMisc
Copy link

Hi,

I don't see any merge request, is anything ongoing? If not, I'll try to submit a AF_UNIX case.

@icraggs
Copy link
Contributor

icraggs commented Jan 14, 2023

I'm not aware of any current work on this, no.

@fpagliughi
Copy link
Contributor Author

Sorry, I haven't have any time to get started on this. I would still love to see it get done, so if anyone else wants to get to it before I have the time, please do so, and I will be happy to review and test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants