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.
Related
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.
I am trying to connect my local mqtt broker to DIoTY cloud broker. I have taken reference from https://www.losant.com/blog/how-to-configure-mosquitto-bridge-to-losant and done all the configuration file changes as required. My /etc/mosquitto/mosquitto.conf looks like
# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
I made my separate cloud.conf file in conf.d
# Config file for mosquitto
# See mosquitto.conf(5) for more information.
user mosquitto
max_queued_messages 200
message_size_limit 0
allow_zero_length_clientid true
allow_duplicate_messages false
listener 1883
autosave_interval 900
autosave_on_changes false
persistence true
persistence_file mosquitto.db
allow_anonymous true
connection dioty
address mqtt.dioty.co:1883
bridge_attempt_unsubscribe false
remote_username *******
remote_password *******
start_type automatic
bridge_protocol_version mqttv311
notifications false
try_private true
bridge_insecure false
cleansession false
topic # in 0
Mosquitto logs after starting broker are as follows
1608537228: mosquitto version 1.6.12 starting
1608537228: Config loaded from /etc/mosquitto/mosquitto.conf.
1608537228: Opening ipv4 listen socket on port 1883.
1608537228: Opening ipv6 listen socket on port 1883.
1608537228: mosquitto version 1.6.12 running
1608539039: Saving in-memory database to /var/lib/mosquitto/mosquitto.db.
What I think is my local mqtt is not reading .conf file. How can I fix this?
You are using Losant configuration to configure DIOTY broket which won't work as both are a different broker.
To save credentials in mosquitto config, first, you have to generate the password file using mosquitto_passwd
mosquitto_passwd -c /etc/mosquitto/passwd USER PASSWORD
then add password file location to mosquitto config also set allow_anonymouse=false
allow_anonymous false
password_file /etc/mosquitto/passwd
That's it now you just need to publish or subscribe using
mosquitto_pub -h localhost -t "test" -m "hello world
mosquitto_sub -h localhost -t test
I have setup Mosquitto MQTT with SSL on port 8883. However when I try and connect I get an error "Error: A TLS error occurred"
I looked up the mosquitto logs and I see "SSL is disabled" in the logs.
I don't think that's expected.
All the certificates are valid.
My config File (Note: mqtt.test.com is not the actual host):
autosave_interval 1800
# Persistence Settings
persistence true
persistence_file mosquitto.db
persistence_location /tmp/
connection_messages true
# Logging Settings
log_timestamp true
log_dest file /home/ubuntu/mqtt/mosquitto/mosquitto.log
log_type debug
# Port Settings
listener 1883
# Only needed if Websockets
listener 8033
protocol websockets
certfile /etc/letsencrypt/live/mqtt.test.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.taggle.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.test.com/privkey.pem
listener 8883
certfile /etc/letsencrypt/live/mqtt.test.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.test.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.test.com/privkey.pem
There is no need to build mosquitto from source to user the auth_plugin, you need access to the matching src bundle for the version of the broker you have installed.
When you built mosquitto you most likely didn't have the openssl dev packages installed to allow the build to link against openssl.
That or you built mosquitto with make WITH_TLS=no
Double check you followed all the instructions in the readme.md that comes with the src and that installed all the prerequisite packages
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.
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?