Tutorial

How to Install and Secure the Mosquitto MQTT Messaging Broker on Ubuntu 16.04

How to Install and Secure the Mosquitto MQTT Messaging Broker on Ubuntu 16.04
Not using Ubuntu 16.04?Choose a different version or distribution.
Ubuntu 16.04

Introduction

MQTT is a machine-to-machine messaging protocol, designed to provide lightweight publish/subscribe communication to “Internet of Things” devices. It is commonly used for geo-tracking fleets of vehicles, home automation, environmental sensor networks, and utility-scale data collection.

Mosquitto is a popular MQTT server (or broker, in MQTT parlance) that has great community support and is easy to install and configure.

In this tutorial, we’ll install Mosquitto, retrieve SSL certificates from Let’s Encrypt, and set up our broker to use SSL to secure our password-protected MQTT communications.

Prerequisites

Before starting this tutorial, you will need:

Step 1 — Installing Mosquitto

Ubuntu 16.04 has a fairly recent version of Mosquitto in its default software repository. Log in with your non-root user and install Mosquitto with apt-get.

  1. sudo apt-get install mosquitto mosquitto-clients

By default, Ubuntu will start the Mosquitto service after install. Let’s test the default configuration. We’ll use one of the Mosquitto clients we just installed to subscribe to a topic on our broker.

Topics are labels that you publish messages to and subscribe to. They are arranged as a hierarchy, so you could have sensors/outside/temp and sensors/outside/humidity, for example. How you arrange topics is up to you and your needs. Throughout this tutorial we will use a simple test topic to test our configuration changes.

Log in to your server a second time, so you have two terminals side-by-side. In the new terminal, use mosquitto_sub to subscribe to the test topic:

  1. mosquitto_sub -h localhost -t test

-h is used to specify the hostname of the MQTT server, and -t is the topic name. You’ll see no output after hitting ENTER because mosquitto_sub is waiting for messages to arrive. Switch back to your other terminal and publish a message:

  1. mosquitto_pub -h localhost -t test -m "hello world"

The options for mosquitto_pub are the same as mosquitto_sub, though this time we use the additional -m option to specify our message. Hit ENTER, and you should see hello world pop up in the other terminal. You’ve sent your first MQTT message!

Enter CTRL+C in the second terminal to exit out of mosquitto_sub, but keep the connection to the server open. We’ll use it again for another test in Step 5.

Next, we’ll secure our installation with SSL using Certbot, the new Let’s Encrypt client.

Step 2 — Installing Certbot for Let’s Encrypt Certificates

Let’s Encrypt is a new service offering free SSL certificates through an automated API. There are many clients that can talk to the API, and Ubuntu includes the official client in their default repository, but it’s a bit out of date and lacks one important feature we need.

Instead, we’ll install the official client from an Ubuntu PPA, or Personal Package Archive. These are alternative repositories that package more recent or more obscure software. First, add the repository.

  1. sudo add-apt-repository ppa:certbot/certbot

You’ll need to press ENTER to accept. Afterwards, update the package list to pick up the new repository’s package information.

  1. sudo apt-get update

And finally, install the official Let’s Encrypt client, called certbot.

  1. sudo apt-get install certbot

Now that we have certbot installed, let’s run it to get our certificate.

Step 3 — Running Certbot

certbot needs to answer a cryptographic challenge issued by the Let’s Encrypt API in order to prove we control our domain. It uses ports 80 (HTTP) and/or 443 (HTTPS) to accomplish this. We’ll only use port 80, so let’s allow incoming traffic on that port now:

  1. sudo ufw allow http
Output
Rule added

We can now run Certbot to get our certificate. We’ll use the --standalone option to tell Certbot to handle the HTTP challenge request on its own, and --standalone-supported-challenges http-01 limits the communication to port 80. -d is used to specify the domain you’d like a certificate for, and certonly tells Certbot to just retrieve the certificate without doing any other configuration steps.

  1. sudo certbot certonly --standalone --standalone-supported-challenges http-01 -d mqtt.example.com

When running the command, you will be prompted to enter an email address and agree to the terms of service. After doing so, you should see a message telling you the process was successful and where your certificates are stored.

We’ve got our certificates. Now we need to make sure Certbot renews them automatically when they’re about to expire.

Step 4 — Setting up Certbot Automatic Renewals

Let’s Encrypt’s certificates are only valid for ninety days. This is to encourage users to automate their certificate renewal process. We’ll need to set up a regularly run command to check for expiring certificates and renew them automatically.

To run the renewal check daily, we will use cron, a standard system service for running periodic jobs. We tell cron what to do by opening and editing a file called a crontab.

  1. sudo crontab -e

You’ll be prompted to select a text editor. Choose your favorite, and you’ll be presented with the default crontab which has some help text in it. Paste in the following line at the end of the file, then save and close it.

crontab
. . .
15 3 * * * certbot renew --noninteractive --post-hook "systemctl restart mosquitto"

The 15 3 * * * part of this line means “run the following command at 3:15 am, every day”. The renew command for Certbot will check all certificates installed on the system and update any that are set to expire in less than thirty days. --noninteractive tells Certbot not to wait for user input.

--post-hook "systemctl restart mosquitto" will restart Mosquitto to pick up the new certificate, but only if the certificate was renewed. This post-hook feature is what older versions of the Let’s Encrypt client lacked, and why we installed from a PPA instead of the default Ubuntu repository. Without it, we’d have to restart Mosquitto every day, even if no certificates were actually updated. Though your MQTT clients should be configured to reconnect automatically, it’s wise to avoid interrupting them daily for no good reason.

Now that automatic certificate renewal is all set, we’ll get back to configuring Mosquitto to be more secure.

Step 5 — Configuring MQTT Passwords

Let’s configure Mosquitto to use passwords. Mosquitto includes a utility to generate a special password file called mosquitto_passwd. This command will prompt you to enter a password for the specified username, and place the results in /etc/mosquitto/passwd.

  1. sudo mosquitto_passwd -c /etc/mosquitto/passwd sammy

Now we’ll open up a new configuration file for Mosquitto and tell it to use this password file to require logins for all connections:

  1. sudo nano /etc/mosquitto/conf.d/default.conf

This should open an empty file. Paste in the following:

/etc/mosquitto/conf.d/default.conf
allow_anonymous false
password_file /etc/mosquitto/passwd

allow_anonymous false will disable all non-authenticated connections, and the password_file line tells Mosquitto where to look for user and password information. Save and exit the file.

Now we need to restart Mosquitto and test our changes.

  1. sudo systemctl restart mosquitto

Try to publish a message without a password:

  1. mosquitto_pub -h localhost -t "test" -m "hello world"

The message should be rejected:

Output
Connection Refused: not authorised. Error: The connection was refused.

Before we try again with the password, switch to your second terminal window again, and subscribe to the ‘test’ topic, using the username and password this time:

  1. mosquitto_sub -h localhost -t test -u "sammy" -P "password"

It should connect and sit, waiting for messages. You can leave this terminal open and connected for the rest of the tutorial, as we’ll periodically send it test messages.

Now publish a message with your other terminal, again using the username and password:

  1. mosquitto_pub -h localhost -t "test" -m "hello world" -u "sammy" -P "password"

The message should go through as in Step 1. We’ve successfully added password protection to Mosquitto. Unfortunately, we’re sending passwords unencrypted over the internet. We’ll fix that next by adding SSL encryption to Mosquitto.

Step 6 — Configuring MQTT SSL

To enable SSL encryption, we need to tell Mosquitto where our Let’s Encrypt certificates are stored. Open up the configuration file we previously started:

  1. sudo nano /etc/mosquitto/conf.d/default.conf

Paste in the following at the end of the file, leaving the two lines we already added:

/etc/mosquitto/conf.d/default.conf
. . .
listener 1883 localhost

listener 8883
certfile /etc/letsencrypt/live/mqtt.example.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.com/privkey.pem

We’re adding two separate listener blocks to the config. The first, listener 1883 localhost, updates the default MQTT listener on port 1883, which is what we’ve been connecting to so far. 1883 is the standard unencrypted MQTT port. The localhost portion of the line instructs Mosquitto to only bind this port to the localhost interface, so it’s not accessible externally. External requests would have been blocked by our firewall anyway, but it’s good to be explicit.

listener 8883 sets up an encrypted listener on port 8883. This is the standard port for MQTT + SSL, often referred to as MQTTS. The next three lines, certfile, cafile, and keyfile, all point Mosquitto to the appropriate Let’s Encrypt files to set up the encrypted connections.

Save and exit the file, then restart Mosquitto to update the settings:

  1. sudo systemctl restart mosquitto

Update the firewall to allow connections to port 8883.

  1. sudo ufw allow 8883
Output
Rule added

Now we test again using mosquitto_pub, with a few different options for SSL:

  1. mosquitto_pub -h mqtt.example.com -t test -m "hello again" -p 8883 --capath /etc/ssl/certs/ -u "sammy" -P "password"

Note that we’re using the full hostname instead of localhost. Because our SSL certificate is issued for mqtt.example.com, if we attempt a secure connection to localhost we’ll get an error saying the hostname does not match the certificate hostname (even though they both point to the same Mosquitto server).

--capath /etc/ssl/certs/ enables SSL for mosquitto_pub, and tells it where to look for root certificates. These are typically installed by your operating system, so the path is different for Mac OS, Windows, etc. mosquitto_pub uses the root certificate to verify that the Mosquitto server’s certificate was properly signed by the Let’s Encrypt certificate authority. It’s important to note that mosquitto_pub and mosquitto_sub will not attempt an SSL connection without this option (or the similar --cafile option), even if you’re connecting to the standard secure port of 8883.

If all goes well with the test, we’ll see hello again show up in the other mosquitto_sub terminal. This means your server is fully set up! If you’d like to extend the MQTT protocol to work with websockets, you can follow the final step.

Step 7 — Configuring MQTT Over Websockets (Optional)

In order to speak MQTT using JavaScript from within web browsers, the protocol was adapted to work over standard websockets. If you don’t need this functionality, you may skip this step.

We need to add one more listener block to our Mosqiutto config:

  1. sudo nano /etc/mosquitto/conf.d/default.conf

At the end of the file, add the following:

/etc/mosquitto/conf.d/default.conf
. . .
listener 8083
protocol websockets
certfile /etc/letsencrypt/live/mqtt.example.com/cert.pem
cafile /etc/letsencrypt/live/mqtt.example.com/chain.pem
keyfile /etc/letsencrypt/live/mqtt.example.com/privkey.pem

This is mostly the same as the previous block, except for the port number and the protocol websockets line. There is no official standardized port for MQTT over websockets, but 8083 is the most common.

Save and exit the file, then restart Mosquitto.

  1. sudo systemctl restart mosquitto

Now, open up port 8083 in the firewall.

  1. sudo ufw allow 8083

To test this functionality, we’ll use a public, browser-based MQTT client. There are a few out there, but the Eclipse Paho JavaScript Client is simple and straightforward to use. Open the Paho client in your browser. You’ll see the following:

Paho Client Screen

Fill out the connection information as follows:

  • Host should be the domain for your Mosquitto server, mqtt.example.com.
  • Port should be 8083.
  • ClientId can be left to the default value, js-utility-DI1m6.
  • Path can be left to the default value, /ws.
  • Username should be your Mosquitto username; here, we used sammy.
  • Password should be the password you chose.

The remaining fields can be left to their default values.

After pressing Connect, the Paho browser-based client will connect to your Mosquitto server.

To publish a message, navigate to the Publish Message pane, fill out Topic as test, and enter any message in the Message section. Next, press Publish. The message will show up in your mosquitto_sub terminal.

Conclusion

We’ve now set up a secure, password-protected MQTT server, with auto-renewing SSL certificates from the Let’s Encrypt service. This will serve as a robust and secure messaging platform for whatever projects you dream up. Some popular software and hardware that works well with the MQTT protocol includes:

  • OwnTracks, an open-source geo-tracking app you can install on your phone. OwnTracks will periodically report position information to your MQTT server, which you could then store and display on a map, or create alerts and activate IoT hardware based on your location.
  • Node-RED is a browser-based graphical interface for ‘wiring’ together the Internet of Things. You drag the output of one node to the input of another, and can route information through filters, between various protocols, into databases, and so on. MQTT is very well supported by Node-RED.
  • The ESP8266 is an inexpensive wifi microcontroller with MQTT capabilities. You could wire one up to publish temperature data to a topic, or perhaps subscribe to a barometric pressure topic and sound a buzzer when a storm is coming!

These are just a few popular examples from the MQTT ecosystem. There is much more hardware and software out there that speaks the protocol. If you already have a favorite hardware platform, or software language, it probably has MQTT capabilities. Have fun getting your “things” talking to each other!

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the author(s)

Brian Boucheron
Brian Boucheron
See author profile

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
26 Comments
Leave a comment...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

I’m trying to follow this on ubuntu 14.04 and I get the following error after I added the requirement for certificates: Unable to connect (Lookup error.).

I had a typo in my config. How can I connect to my mqtt server using another computer? Do I have to transfer the certificates?

Ok, I just need to provide the path to my certs.

I’m glad you got things working. You might want a more up-to-date version of Mosquitto… I don’t think the version included with 14.04 supports websockets, for instance. You can find a PPA with recent versions here:

https://launchpad.net/~mosquitto-dev/+archive/ubuntu/mosquitto-ppa

how you solve that…? am facing the same error…

Unable to connect (Lookup error.).

Great guide! Very handy.

However I’m a bit confused. In step six you say:

$ sudo chgrp -R mosquitto /etc/letsencrypt/archive/mqtt.example.com/

But then later you configure references to certs in /etc/letsencrypt/live, not /etc/letsencrypt/archive. Is this a typo?

Thanks, Travis.

Hello,

If you execute ls -l in /etc/letsencrypt/live you can see that the files are linked to /etc/letsencrypt/archive.

I found that out shortly after posting the question, as is so often the case, but I’m still having issues. A mosquitto group didn’t exist on my system, so I made one and added the mosquitto user to it. I followed the guide and gave that user access to the cert archive directory, but:

root@server:~# sudo -u mosquitto cat /etc/letsencrypt/archive/server.com/chain1.pem
cat: /etc/letsencrypt/archive/server.com/chain1.pem: Permission denied
root@server:~# sudo -u mosquitto id
uid=110(mosquitto) gid=1002(mosquitto) groups=1002(mosquitto)
root@server:~# ls -la /etc/letsencrypt/archive/server.com/
total 24
drwxr-sr-x 2 root mosquitto 4096 Dec 30 23:09 .
drwx------ 3 root root      4096 Dec 30 23:09 ..
-rw-r--r-- 1 root mosquitto 1793 Dec 30 23:09 cert1.pem
-rw-r--r-- 1 root mosquitto 1647 Dec 30 23:09 chain1.pem
-rw-r--r-- 1 root mosquitto 3440 Dec 30 23:09 fullchain1.pem
-rw-r--r-- 1 root mosquitto 1704 Dec 30 23:09 privkey1.pem

and

mosquito.log

1483107733: mosquitto version 1.3.4 (build date 2014-08-17 00:14:52-0300) starting
1483107733: Config loaded from /etc/mosquitto/mosquitto.conf.
1483107733: Opening ipv4 listen socket on port 1883.
1483107733: Opening ipv4 listen socket on port 8883.
1483107733: Opening ipv6 listen socket on port 8883.
1483107733: Error: Unable to load CA certificates. Check cafile "/etc/letsencrypt/live/server.com/chain.pem".

I’m not sure where I’ve gone wrong here. I’ve rebooted the server since adding the user mosquitto to the mosquitto group For now I’ve moved the certs into the mosquitto directory, but when they expire things will fail.

Thanks, Travis.

Are you using Debian? I’ve been working on adapting this tutorial for Debian Jessie, and your problems all sound familiar.

It’ll be a bit before the updated tutorial is posted, but I just did a complete run-through and everything is working. The key is installing a newer version of Mosquitto. Check their downloads page for a Debian repository with more up-to-date packages. You’ll want to do this anyways, because 1.3.4 doesn’t support websockets and some other handy features.

The new package installs the mosquitto group, so you wont need to mess with adding that. Everything else should be mostly the same as well.

Yep, I’m running Debian Jessie, with whichever version of mosquitto was available via apt-get approx. 2016-12-29.

I’ve got mine working now, I had to change the permissions on /etc/letsencrypt/archive/ in order to give users of the mosquitto group access to the subdirectory.

chgrp mosquitto /etc/letsencrypt/archive
chmod 750 /etc/letsencrypt/archive

Or something like that. This allowed mosquitto to access the certs.

Thanks, Travis

I followed this tutorial and everthing works great, except sometimes the broker randomly stop and i have to manually restart the service with sudo service mosquitto restart

does anyon know why ?? last lines in mosquitto.log are saying that a socket connection errored…

1485943735: Socket error on client mqttjs_abceadb0, disconnecting.
1485943737: New client connected from 84.196.75.214 as mqttjs_abceadb0 (c1, k10, u'mosquitto').
1485943757: Socket error on client mqttjs_abceadb0, disconnecting.
1485943758: New client connected from 84.196.75.214 as mqttjs_abceadb0 (c1, k10, u'mosquitto').
1485943761: Socket error on client mqttjs_abceadb0, disconnecting.
1485943765: New client connected from 84.196.75.214 as mqttjs_f93571fe (c1, k10, u'mosquitto').

hy i m stuck at step 6 kindly help me to solve this when i m start publishing or sub this msg show below “Unable to connect (Lookup error.).”

hy i m stuck at step 6 kindly help me to solve this when i m start publishing or sub this msg show below “Unable to connect (Lookup error.).”

This looks like a DNS lookup issue. Did you make sure to substitute your own domain name for mqtt.example.com? Also make sure you’ve made a DNS record for the name you’re using. You could run host your.domain.name.com (again, making sure to substitute your actual domain) to see if it resolves properly.

Error: Connection refused

i got this error

**Password authentication NOT WORKING in digital ocean cloud ubuntu 16.04?..

Your tutorial work fine on my personal computer (ubuntu 16.04), username and password authentication is working, as show in tutorial authenticate with username and password after config mosquitto_passw.

??? But password authentication NOT WORKING in digital ocean cloud ubuntu 16.04, like after config mosquitto_passw it just connect (pub and sub) without authentication (username and password).

I can’t understand why? please help me what I am missing!..********

After executing the last line in Step6 (command for publish), I am getting an error ‘A TLS error occurred’.

What could be the reason of the error.? Thanks in advance.

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mosquitto.plist /usr/local/Cellar/mosquitto/1.4.11_2/homebrew.mxcl.mosquitto.plist: Operation not permitted

If you are leaving a tutorial, make sure the goddamn thing actually works. Otherwise do not bother.

It appears you are attempting to install Mosquitto on a Mac. This article is written for (and tested on) Ubuntu 16.04. It will likely need small changes for other Linux distributions, and significant modifications for MacOS.

Is there any way to view the users that have been created?

Great tutorial Brian. Everything works perfectcly from my ssh console, but when I try to connect with a client, I find it impossible, being Android, web, or Windows client, to 8883 and to 1883 for which I removed the localhost constraint to check.

Of course the network connection to the host works because I’m logged in through SSH to work on it.

Do you have any idea or suggestion on how could I debug it?

Brian Boucheron
DigitalOcean Employee
DigitalOcean Employee badge
August 22, 2017

Did you check your firewall settings? sudo ufw status should show 8883 open (and 1883 if you’re just testing that as well). Additionally, if you could paste in the output of netstat -plut we can check to make sure that mosquitto is actually listening on the correct interfaces.

Hello Brian, I checked the configuration again and tried a client from my phone. Seems my workplace proxy was blocking the port. Everything is working like a charm now, fantastic tutorial!

Sorry to bother.

First thanks for the tutorial. It helped me a lot. I got it running on Ubuntu 14 LTS. Some small notes about how I got it working (for future generations).

  • Installing mosquitto came without mosquitto_passwd. So I had to follow the steps on http://gobowen.com/content/installing-mosquitto-ubuntu-1404
  • In order to generate the keys I had to stop my webserver.
  • The final and last part was testing with a remote mosquitto_pub client. It took me quite some digging before I came to understand that I had to point to a specific CA pem when doing a message publish. Like this:
mosquitto_pub -h mqtt.example.com -t test -m "hello again" -p 8883 --cafile /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem -d -u "sammy" -P "p@zw0rD"

The /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem is the file containing the certificates on my Fedora 26 machine.

Hello everyone, thank you very much for these very well done tutorials that I really use often. Regarding this one, I do not quite understand how to publish from a client on another server with a certificate. Do I have to copy on each of my clients, who wants to communicate, the certificates generated on the server? What does the renewal of Let’s Encrypt means every 3 months, do I have to copy the new certificates to my clients each time I renew Let’s Encrypt?

Thank you for your help

Brian Boucheron
DigitalOcean Employee
DigitalOcean Employee badge
November 10, 2017

If you’re using Let’s Encrypt you shouldn’t have to copy any certificates over to your clients, no. Renewal should be fully automated and again, you’ll not need to copy anything to your clients afterwards.

Thank you for your reply. Ok, in my opinion I did not understand the operation of Let’s Encrypt because for me, the client needs a certificate to encrypt the communication. If the client does not have a certificate, how can he encrypt the messages? In the mosquitto_pub command, the options for specifying certificate paths are therefore server-side paths?

Did you figure this question out? because I am totally confused by this as well… also this path --capath /etc/ssl/certs/ … doesn’t seem to have anything to do with what is said in the tutorial. how is all of this cert stuff related? from what I understood the certificates are in directory: /etc/letsencrypt/live/mqtt.example.com/ and mosquitto can reference that directory with the file stored in: /etc/mosquitto/conf.d/default.conf where we are instructed to type in the path… so again what is --capath /etc/ssl/certs/ and what does the client need in order to access the broker. my failing client is paho on python

Hi m8! First of all ty for this tutorial its amazing. I’m working in app using mqtt vps and raspberry pi 3. Raspberry Pi receives data from DHT11 sensor via GPIO, now I want to transfer data to a VPS. I’m using mqtt broker in the VPS and I want to use NODE-RED can you help me? I dont know hot to communicate RPi and VPS properly. Thank you

Excellent Tutorial, Worked like a charm!

I followed this tutorial and my mqtt broker and client worked fine over TLS on my VPS. However, when I tried to connect my mqtt broker from a local ubuntu machine with mosquitto_clients, I got an error “Unable to connect (A TLS error occurred.).

Nice, it works =)

I would like to create a bridge from my local broker (mosquitto on centos) to my secured digital oceans server (mosquitto in ubuntu). Any guide or help about this topic? Couldn’t find info about it :S

Nice article!

by Go

Thank you for the recipe. I’m actually using 2 Mosquitto servers now. The existing one for the intranet runs on the standard MQTT port 1883 without passwords and is used by already running ESP nodes on the LAN. The new one on the other port (8883) has TLS and user/password authorization and is reachable from the internet. It just forwards all messages to the first server using the bridge configuration. This has proven to work very well with off-site MQTT nodes for almost three months…

Alas, now the time for renewal of the certificate has come, and the crontab call fails. The server runs behind a NAT router (AVM FritzBox), all relevant ports have been exposed to the outside. I now get an “unexpected error” saying:

Failed authorization procedure. xxyyzz.defdc.com (tls-sni-01): urn:acme:error:unauthorized :: The client lacks sufficient authorization :: Incorrect validation certificate for tls-sni-01 challenge. Requested f5xxxcc.6cxxx18.acme.invalid from 87.xx.yy.zz:443. Received 1 certificate(s), first certificate had names “fritz.box, fritz.nas, xxyyzz.mooo.com, myfritz.box, www.fritz.box, www.fritz.nas, www.myfritz.box”.

xxyyzz.defdc.com and xxyyzz.mooo.com are both Dynamic DNS domains resolving correctly to the cited IPv4 address. All “fritz” domains are made up by the FritzBox, I suppose. I already tried different options to “certbot renew”, but got errors in each case.

Any chance to renew the certificate (even manually)? Or do I have to recreate it completely with different parameters? (which ones?)

i tried to configure bridge local to cloud mosquito server. am getting this error in cloud mosquitto server log.

OpenSSL Error: error:140780E5:SSL routines:ssl23_read:ssl handshake failure

please help me which files need to be add in bridge configuration.

Hi, I am always getting this error, can anyone help me please

Failed authorization procedure. mqtt.example.com (http-01): urn:acme:error:dns :: DNS problem: NXDOMAIN looking up A for mqtt.example.com

IMPORTANT NOTES:

mosquitto_sub -h motorinkz.in -t test -p 1883 -u “username” -P “password” . when am hitting enter it showing as connection refused but when i change the ports (i.e) -p 8883 or 8083 mosquitto_sub doesnt show any error its ready to receive message from mosquito_pub, but when i type mosquitto_pub -h motorinkz.in -t test -p 8883 0r 8083 -u “username” -P “password” -m hello. it shows Error: the connection was lost. please explain me why it happens and give me a solution

i tried to configure bridge local to cloud mosquito server. am getting this error in cloud mosquitto server log.

OpenSSL Error: error:140780E5:SSL routines:ssl23_read:ssl handshake failure

please someone help me which files need to be add in bridge configuration.

I am Totally new to this,I want to run simple_subscriber and simple_publisher in Ubuntu 14.04 .I tried buy ./bin/simple_subscriber and same for publisher in other terminal.But data not received by subscriber .I downloaded application from following git account and compiled it. –>https://github.com/LiamBindle/MQTT-C.git SUBSCRIBER RUNNING********** akbarsaleem@IM-PC-102:~/akbar/mqqt2/MQTT-C/bin$ ./simple_subscriber 127.0.0.1 1888 ./simple_subscriber listening for ‘datetime’ messages. Press CTRL-D to exit.

./simple_subscriber disconnecting from 127.0.0.1 akbarsaleem@IM-PC-102:~/akbar/mqqt2/MQTT-C/bin$**

PUBLISHER*** akbarsaleem@IM-PC-102:~/akbar/mqqt2/MQTT-C/bin$ ./simple_publisher 127.0.0.1 1883 ./simple_publisher is ready to begin publishing the time. Press ENTER to publish the current time. Press CTRL-D (or any other key) to exit.

./simple_publisher published : “The time is 2019-07-30 17:58:35” ./simple_publisher published : "The time is 2019-07-30 17:58:41"akbarsaleem@IM-PC-102:~/akbar/mqqt2/MQTT-C/bin$

Please provide me details to run subscriber and publisher.

This needs to be updated as the Paho JavaScript client is no longer available publicly and needs to be downloaded. Is there any other publicly available MQTT browser based clients?

HI, could you please help me? I’m starting learning and install let’s encrypt certificate with DNS challenge. I dont have pem.file but inside the folder /home/pi/.acme.sh/example.com I have these files: example.com.cer example.com.conf example.com.csr example.com.csr.conf example.com.key ca.cer fullchain.cer. Which ones are the certfile, cafile, and keyfile? I’ve tryed several combination looking at the names but the command mosquitto_pub -h example.com -t test -m “hello again” -p 8883 --capath /etc/ssl/certs/ -u “sammy” -P “password” doesn’t work. Moreover inside the /etc/ssl/certs/ I don’t find the certificate. Thanks a lot

Hi, I believe there may something missing in step 5. When creating the default.conf file there should be a line listener 1883 added as well. If not the restart won’t change anything and publish without username and password will still be possible.

This comment has been deleted

    Hi, so this is outdated when using new ubuntu 22.10 - @DO team, please mention this or take it offline, took me 2 hours trying to work this out before I realized it might be a version/compatibility issue. Please refer to this link: https://www.howtoforge.com/how-to-install-and-secure-the-mosquitto-mqtt-messaging-broker-on-ubuntu-20-04/

    The /etc/mosquitto/conf.d/default.conf should be like below

    per_listener_settings true
    allow_anonymous false
    password_file /etc/mosquitto/passwd
    
    

    because the given default.conf is not working until you add the line per_listener_settings true

    Join the Tech Talk
    Success! Thank you! Please check your email for further details.

    Please complete your information!

    Become a contributor for community

    Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

    DigitalOcean Documentation

    Full documentation for every DigitalOcean product.

    Resources for startups and SMBs

    The Wave has everything you need to know about building a business, from raising funding to marketing your product.

    Get our newsletter

    Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

    New accounts only. By submitting your email you agree to our Privacy Policy

    The developer cloud

    Scale up as you grow — whether you're running one virtual machine or ten thousand.

    Get started for free

    Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

    *This promotional offer applies to new accounts only.