Error creating bridge: Permission denied Mosquitto - mqtt

I trying run mosquitto on embedded linux device with configuration (show below) as root user and cmd: mosquitto -c /etc/mosquitto/mosquitto.conf
### /etc/mosquitto/mosquitto.conf ###
log_dest stdout
#mosquitto user
user mosquitto
#bridge Config
connection 1234567890
address 192.168.0.101:1883
start_type automatic
topic # both 0
topic # both 1
#cleansession false
bridge_protocol_version mqttv311
#need to be false otherwise error on hivemq-side
notifications false
### end of conf file ###
mosquitto can't created bridge and I catch this log:
1472052730: mosquitto version 1.4.8 (build date 2016-07-05 08:47:49+0200) starting
1472052731: Config loaded from /etc/mosquitto/mosquitto.conf.
1472052731: Opening ipv4 listen socket on port 1883.
1472052731: Opening ipv6 listen socket on port 1883.
1472052731: Connecting bridge 1234567890 (localhost:1883)
1472052731: Error creating bridge: Permission denied.
1472052731: Warning: Unable to connect to bridge 1234567890.
1472052761: Connecting bridge 1234567890 (localhost:1883)
However when I change user in conf file from mosquitto to root (but I know it's not correct) everything works fine.
Can you help me resolved this problem?

Related

Mosquitto bridge mode error "Client local.XXXXXX.awsiot disconnected: protocol error."

I'm trying to create a bridge between my local mosquitto broker and AWS IOT. Unfortunatelly i cannot succesfully make it work :(((
I setup the mosquitto.config file like that:
port 1883
allow_anonymous true
log_type all
tls_version tlsv1.2
bind_address 0.0.0.0
listener 8883
protocol mqtt
connection awsiot
address al3qi2b1mxp67-ats.iot.us-east-2.amazonaws.com:8883
topic # both 0
try_private false
bridge_protocol_version mqttv311
bridge_keyfile C:\Program Files\mosquitto\certs\private.key
bridge_certfile C:\Program Files\mosquitto\certs\certificate.pem
bridge_cafile C:\Program Files\mosquitto\certs\AmazonRootCA1.pem
I'm getting this result in cmd running command mosquitto.exe -c mosquitto.conf
1642763152: The 'port' option is now deprecated and will be removed in a future version. Please use 'listener' instead.
1642763152: The 'bind_address' option is now deprecated and will be removed in a future version. The behaviour will default to true.
1642763152: mosquitto version 2.0.14 starting
1642763152: Config loaded from mosquitto.conf.
1642763152: Opening ipv6 listen socket on port 8883.
1642763152: Opening ipv4 listen socket on port 8883.
1642763152: Opening ipv4 listen socket on port 1883.
1642763152: Bridge local.DESKTOP-DC703HB.awsiot doing local SUBSCRIBE on topic #
1642763152: Connecting bridge awsiot (al3qi2b1mxp67-ats.iot.us-east-2.amazonaws.com:8883)
1642763152: Bridge DESKTOP-DC703HB.awsiot sending CONNECT
1642763152: mosquitto version 2.0.14 running
1642763153: Client local.DESKTOP-DC703HB.awsiot disconnected: protocol error.

Mosquitto - Unable to connect over network other than on the default port

I am running Mosquitto 1.4.8 on Ubuntu successfully on port 1883 (tested from another machine with mosquitto_sub/mosquitto_pub). However I am encountering issues when attempting to use another port eg.
mosquitto -p 1884 -c moddebug.conf
This works OK if I access it from the same machine e.g.:
mosquitto_pub -h 127.0.0.1 -p 1884
but if I attempt to connect from another machine I get an error:
mosquitto_pub -h IP_ADDRESS -t exmapleTopic -p 1884
Connection timed out
My moddebug.conf file is:
log_type all
log_dest file mosquitto2_log.log
The log does not provide any extra information:
Config loaded from mosdebug.conf.
Opening ipv4 listen socket on port 1884.
Opening ipv6 listen socket on port 1884.
mosquitto version 1.4.8 terminating
I have tried altering the firewall rules (but this did not help):
ufw allow 1884/tcp
Rules updated
Rules updated (v6)

Mosquitto - EMQX bridge connection name

1) How to determine the Mosquitto bridge connection name.
The snippet written below is from the EMQx documentation (http://emqtt.io/docs/v2/bridge.html#mosquitto-conf)
connection emqttd
address 127.0.0.1:2883
topic sensor/# out 2
the connection name - emqttd is written on what basis?
2) I have a tcp connection open from EMQX on the host 172.22.25.53 and port 2883.
When i try connecting from the same system. It works absolutely fine. But from a different system, I get this error
C:\Program Files\mosquitto>mosquitto.exe -c mosquitto.conf -v
1542182003: mosquitto version 1.5.3 starting
1542182003: Config loaded from mosquitto.conf.
1542182003: Opening ipv6 listen socket on port 1883.
1542182003: Opening ipv4 listen socket on port 1883.
1542182003: Bridge local.AOI146.emq#172.22.25.53 doing local SUBSCRIBE on topic BA/#
1542182003: Connecting bridge emq#172.22.25.53 (172.22.25.53:2883)
1542182003: Bridge AOI146.emq#172.22.25.53 sending CONNECT
1542182003: Error creating bridge: Unknown error.
1542182003: Warning: Unable to connect to bridge emq#172.22.25.53.
My mosquitto.conf file is:
connection emqx
address 172.22.25.53:2883
cleansession false
topic AB/# both 2
The connection name is the value after connection in the configuration file. As described in the bridge section of the mosquitto.conf man page
e.g.
connection foo
Will result in a connection name of foo.
172.22.25.53 is in the reserved range 172.16.0.0 – 172.31.255.255, I'm going to guess you are running emq in a docker container and you are trying to access the container using it's Docker internal IP address. You will need to expose the port on your host machine to be able to access it from a remote machine.

Mosquitto giving error on launch

I installed Mosquitto 1.4.9 on my Ubuntu 16.04 machine from source files
I ran a test and things worked fine with localhost but when I tried to connect using my domain I got a connection refused error message.
When I went back to my mosquitto.conf file I found I had made a typo in my url so I corrected the typo (I even tried with the IP Addy in place of the domain).
I then killed the running Mosquitto process and when I ran sudo mosquitto -c /etc/mosquitto/mosquitto.conf
I got the following output:
1513023494: mosquitto version 1.4.9 (build date 2017-12-11 13:46:59-0500) starting
1513023494: Config loaded from /etc/mosquitto/mosquitto.conf.
1513023494: Opening ipv4 listen socket on port 8883.
1513023494: Error: Cannot assign requested address
When I remove the domain and put in localhost I get:
1513024906: mosquitto version 1.4.9 (build date 2017-12-11 13:46:59-0500) starting
1513024906: Config loaded from /etc/mosquitto/mosquitto.conf.
1513024906: Opening ipv4 listen socket on port 8883.
My mosquitto.conf file looks like this:
listener 8883 <domain>.com
persistence true
persistence_location /var/lib/mosquitto/
persistence_file mosquitto.db
log_dest syslog
log_dest stdout
log_dest topic
log_type error
log_type warning
log_type notice
log_type information
connection_messages true
log_timestamp true
allow_anonymous false
password_file /etc/mosquitto/pwfile
As recommended by hardillb,
Removing the FQDN, Localhost, or IP address from the Listener line allowed mosquitto to launch properly and accept connections on the FQDN.

Mosquitto MQTT Bridge Error

I am trying to bridge my local (Windows) MQTT mosquitto broker to test.mosquitto.org. Unfortunately it raises a Unknown Error.
I am using the same configuration that is used in this question
Verify that local mosquitto MQTT Broker is bridged to test.mosquitto.org
Config file:
connection test
address test.mosquitto.org
topic oust_topicst_topic out 0
try_private false
notifications false
bridge_attempt_unsubscribe true
Output:
1489747961: mosquitto version 1.4.11 (build date 20/02/2017 23:24:29.40) starting
1489747961: Config loaded from Configurations/bridge.conf.
1489747961: Opening ipv6 listen socket on port 1883.
1489747961: Opening ipv4 listen socket on port 1883.
1489747961: Bridge local.NicolasJourdan.test doing local SUBSCRIBE on topic oust_topicst_topic
1489747961: Connecting bridge test (test.mosquitto.org:1883)
1489747961: Bridge NicolasJourdan.test sending CONNECT
1489747961: Error creating bridge: Unknown error.
1489747961: Warning: Unable to connect to bridge test.
1489747969: mosquitto version 1.4.11 terminating
What could produce this error? I am not running another instance of mosquitto and test.mosquitto.org is up
First question is whether you are running a local broker or just connecting as a client.
If you are running a broker try to first run mosquitto with -c "path to config file" to see whether your config file has an error in it. Run in terminal (example on linux):
mosquitto -c /etc/mosquitto/mosquitto.conf
If there is an error the console will show it and you take it from there.
Next, try to format your topics like this (it is called topic remapping):
topic test out 0 local/ local/
Now you can publish to local/test from your code or terminal, and the message will be published to local/test on the remote broker, which will receive messages by suscribing to the same topic.
Update September 2019
The bug on Windows as described below has reportedly been fixed in version 1.6.5 of Mosquitto.
There appears to be a bug with Mosquitto running on Windows that prevents bridging from working.
On Windows the socket is not ready before Mosquitto attempts to connect.
See https://github.com/eclipse/mosquitto/issues/478 and https://github.com/eclipse/mosquitto/issues/580. This describes the underlying issue on Windows:
After checking the code I found that the statement in bridge.c .... makes a non blocking socket connect.
...
So the the next command ... sometimes fails, since the connection has not been established, as the previous connect is non-blocking.

Resources