Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
mosquitto_connect() fails on systems with no IPv4 addresses configured. #869
mosquitto_connect() will fail on systems with no IPv4 addresses configured. Even when connecting via the loopback interface to localhost.
From a brief look at the source, I believe this is because net__try_connect (lib/net_mosq.c:300) is using AI_ADDRCONFIG to enumerate local IP addresses to bind to. Per the RFC this fails when the system has no IPv4 addresses configured (lo not being considered a configured address):
This may be related to #736
(internal ID CORE4-909)
Certainly on embedded devices having no IPv4 addresses configured is very common (indeed having no interfaces except loopback is common).
In our case mosquitto is brokering messages between various modules which are themselves attempting to configure the system's IPv4 addresses as part of system startup (but are having a hard time since mosquitto needs the IPv4 addresses to be configured before it will connect...).
Either way I did patch this locally by removing the AI_ADDRCONFIG flag, which seems to work fine on our systems - I don't know if it's compatible with all configurations though.
Thanks @Alex-Richman . It's great If you can submit your patch as a new PR.
I'd like to consult you. Should this issue be treated as a bug by lack of a primitive and nothing special feature, or as a new great and special feature?
If the former, I will label as an enhancement and close this issue, you can submit a new PR and link this close issue. If the latter, I will label as a bug and keep this issue, you can submit a new PR and link this open issue.
referenced this issue
Jul 31, 2018
added a commit
Aug 2, 2018
I've made the change that removes this, if you test the