Difficulty congiguring MQTT

I am trying to setup a mosquitto MQTT broker on a Linux Linode server.
I have read all postings on this forum related to MQTT and many from elsewhere.
I am using mosquitto 2.0.11 on the server.
Currently, I am only trying to connect using userid/password security on port 1883.
It appears to work as expected when used by mosquitto clients running on the server. I can specify localhost or the server's IP address as host.
I have it set to listen on 1883, but interactions from the network appear to be rejected.
I have set the following ufw rules:
[ 7] 1883/udp ALLOW IN Anywhere
[ 8] 1883/tcp ALLOW IN Anywhere

My /etc/mosquitto.conf looks like this:

# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

# PID file location
#----------------------------------
pid_file /run/mosquitto/mosquitto.pid

# persistence maintenence
#----------------------------------
persistence true
persistence_location /var/lib/mosquitto/

# Security settings
#----------------------------------

# settings global or by socket #
#----------------------------------
per_listener_settings false

# anonymous connections (off)
#----------------------------------
# allow_anonymous true
allow_anonymous false

# Listeners
#----------------------------------
listener 1883
# http_dir /home/dataload/data

#listener 8883 # SSL/TLS
#listener 9001 # Websockets - must be compiled in

# Non-listener port (?)
#----------------------------------
# port 1884

# File based password
#----------------------------------
password_file /etc/mosquitto/mosquitto.pwd

# Alternative access control plugins
#----------------------------------
# plugin path/to/mosquitto_dynamic_security.so
# plugin /usr/lib/x86_64-linux-gnu/mosquitto_dynamic_security.so
# plugin_opt_config_file path/to/dynamic-security.json
# to use dynamic: mosquitto_ctrl dynsec init path/to/dynamic-security.json admin-user

# Log location
#----------------------------------
log_dest file /var/log/mosquitto/mosquitto.log

# Extra configuration files
#----------------------------------
#include_dir /etc/mosquitto/conf.d

Example output from remote workstation:
$> mosquitto_pub -h 45.33.xx.xx -u dave -P !!!!!!!! -t testing/tests -m "Testing 123" -d
Error: Connection timed out

$> mosquitto_sub -h 45.33.xx.xx -u dave -P !!!!!!!! -t testing/tests

My systemctl status for mosquitto looks like this:

dave@magdata-01:~/projects/mqtt-dev$ sudo systemctl status mosquitto.service
● mosquitto.service - Mosquitto MQTT Broker
Loaded: loaded (/lib/systemd/system/mosquitto.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2023-01-30 16:33:39 CST; 43min ago
Docs: man:mosquitto.conf(5)
man:mosquitto(8)
Process: 287325 ExecStartPre=/bin/mkdir -m 740 -p /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 287326 ExecStartPre=/bin/chown mosquitto /var/log/mosquitto (code=exited, status=0/SUCCESS)
Process: 287327 ExecStartPre=/bin/mkdir -m 740 -p /run/mosquitto (code=exited, status=0/SUCCESS)
Process: 287328 ExecStartPre=/bin/chown mosquitto /run/mosquitto (code=exited, status=0/SUCCESS)
Main PID: 287329 (mosquitto)
Tasks: 1 (limit: 2237)
Memory: 1.8M
CPU: 1.078s
CGroup: /system.slice/mosquitto.service
└─287329 /usr/sbin/mosquitto -c /etc/mosquitto/mosquitto.conf

Jan 30 16:33:39 magdata-01 systemd[1]: Starting Mosquitto MQTT Broker…
Jan 30 16:33:39 magdata-01 systemd[1]: Started Mosquitto MQTT Broker.

I'm at a loss to know why I cannot interact remotely.

2 Replies

Although I've never used Mosquitto MQTT however, I have troubleshooted plenty of Error: Connection timed out messages. I suggest checking that your firewall rules are in effect using the following command:

nmap -Pn -p 1883 <your.ip.address>

If you're unfamiliar with nmap and it's output, you can find more information in this post from our Community Questions site titled How do I understand the results of an nmap scan?

It's also possible you're experiencing network connectivity issues that are resulting in timeouts. This post can assist in troubleshooting those issues.

Finally, I wanted to provide you with some other resources you may find useful:

Thanks!
I sorted it out. I finally realized that in addition to my running UFW on the instance, there is an off-instance firewall in place as well. I had forgotten about that. When I configured both to pass my traffic, all was well.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct