Setting up an MQTT server

Is it worth setting up an MQTT server instead of using the Meshtastic one? I have a couple of Linux servers I could install on.

If it’s worth doing, which packages do I install (CLI only) and how do I configure them?

I’m brand new to Meshtastic and am just playing around with it at the moment. I have a couple of Heltec V3s and a couple of TBeams. The concept is very interesting, especially for communication in sparsely populated landscapes and for the use of gathering data from various sensors :+1:t2:

2 Likes

I am also interested in doing something very similar. a list of usable CLI only tools would be of great help

All you need is an MQTT broker, I use mosquitto

My preference these days is to use docker, here’s a decent guide on how to set it up using docker:

Otherwise if you’re running ubuntu 18.04 and above: sudo apt install mosquitto mosquitto-clients

There’s some good doco on the meshtastic website as well, and although this says for Mac, the mosquitto_sub and _pub commands for testing are the same, as is the mosquitto.conf

1 Like

I’ve finally got Mosquitto up and running (not in a container though). I just need to test the connection, but this will probably be tomorrow.

I found Mosquitto quite hard to configure… it works locally by default, but I struggled to find documentation to help me set up remote/external connections.

Have you actually got this working for you? I have tried for months on Linux, Mac OS, Windows 10, Docker. Even Hired a guy from India and nothing. I can’t figure any of this out.

Ah, yeah remote access is the harder part.

I actually made a suggestion for another project recently on how to remotely access local network services, which could apply to this: Sharing Your BirdNET-Pi Stuff!!!!!! · mcguirepr89/BirdNET-Pi · Discussion #69 · GitHub

perfect use case for ngrok (How to expose your localhost server using Ngrok | by Reyhan | Medium | Medium).

you’d definitely want to have authentication setup on mosquitto though, as it would be exposed to the public internet, but at least using ngrok its exposed using their IP addresses, rather than your own.

once you have ngrok installed, just a matter of replacing the ngrok http 80 command in the medium guide I linked above with ngrok tcp 1883 and you should be able to connect from the internet/externally on the hostname and port provided, example from my testing:

So you’d connect on port 19520 using the hostname that ngrok provides you with an external mqtt client.

I just tested this using mqtt-explorer on my windows machine and was able to successfully connect to my mosquitto server that i’d exposed using ngrok on the hostname that is displayed once you run ngrok

1 Like

I did get it working in the end but I’ve gone back to the Meshtastic MQTT broker to pick up more traffic. I’ll keep mine running in case I ever get any friends or family onboard :grimacing:

1 Like

I got mine running about 70% on windows 10. The remote access was the easier part. What I did was went into the router and told it to reserve the IP address in the LAN to the computer that is hosting the broker. Then I went into the modem and forward’d the port 1883 to the IP address in the LAN that is the computer running the broker. Next I obtained my public IP address, let’s say 12.345.678 (the one the internet company gives you) and used that as my address for the server. Then I went into meshtastic’s MQTT config section and for the “MQTT server address” I used my 12.345.678 then added the port 1883 so it should look like this 12.345.678:1883. When you modem at 12.345.678 gets the request for port 1883, the port forward rule will tell it where to send it. NOTE: This will not work if you are already on your LAN.

My issue… i can only see the 2 nodes that are directly connected to the broker. The other nodes in the mesh, despite being seen by the broker node, won’t go through the broker. Still working on that.

Hope this helps. I’ve spend months on this project.

2 Likes

Can I get a copy of your mosquito.conf
I’m trying to setup a MQTT server for my group.
Can’t find instructions anywhere.

Have you tried the mosquitto website for doco?

The file is unique to your situation. If you were using ACL’s and/or user accounts, you would have to specify in the config file where theses are located. I believe if something is incorrect, the broker won’t start so it’s got to be pretty accurate.