<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Mosquito on Philly Mesh</title><link>https://prm.boda.dev/tags/mosquito/</link><description>Philly Mesh (Mosquito)</description><generator>Hugo -- gohugo.io</generator><language>en-us</language><lastBuildDate>Mon, 24 Mar 2025 00:00:02 +0000</lastBuildDate><atom:link href="https://prm.boda.dev/tags/mosquito/index.xml" rel="self" type="application/rss+xml"/><item><title>MQTT Bridge Setup</title><link>https://prm.boda.dev/2025/03/24/mqtt-bridge-setup/</link><pubDate>Mon, 24 Mar 2025 00:00:02 +0000</pubDate><author>Mike Dank (Famicoman)</author><guid>https://prm.boda.dev/2025/03/24/mqtt-bridge-setup/</guid><description>&lt;p>In August 2024 Meshtastic made changes to their official MQTT server due to potential safety issues of third parties tracking and storing user location data. While one of the main Meshtastic node mapping websites &lt;a href="https://meshmap.net/">meshmap.net&lt;/a> continues to rely on the official MQTT server, another popular site &lt;a href="https://meshtastic.liamcottle.net/">meshtastic.liamcottle.net&lt;/a> now runs their own separate MQTT server.&lt;/p>
&lt;p>While MQTT can be leveraged to connect Meshtastic nodes to one another over-the-Internet to bridge separated networks or isolated nodes, many people instead use this feature specifically for contributing to node maps so others can see what nodes may be operating in their area. As already outlined, there are now two separate MQTT servers for node maps. However, the Meshtastic application only allows one MQTT server to be configured per node, which requires the user to make a choice of which one they will use and ultimately which site they will not contribute to.&lt;/p>
&lt;p>Luckily, there is another approach that can be used to reliably send data to multiple MQTT servers: creating an MQTT bridge. This bridge can act as an intermediary, allowing Meshtastic nodes to send it data which is then forwarded to other servers.&lt;/p>
&lt;p>Here we can see how to set up a server that feeds to both &lt;code>mqtt.meshtastic.org&lt;/code> and &lt;code>mqtt.meshtastic.liamcottle.net&lt;/code>.&lt;/p>
&lt;h2 id="installation--base-config" >Installation &amp;amp; Base Config
&lt;span>
&lt;a href="#installation--base-config" title="Direct Link to Installation &amp;amp; Base Config">
&lt;svg viewBox="0 0 28 23" height="100%" width="19" alt="" xmlns="http://www.w3.org/2000/svg">&lt;path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;/svg>
&lt;/a>
&lt;/span>
&lt;/h2>
&lt;p>This guide assumes a Debian Linux system with a non-root, &lt;code>sudo&lt;/code> user.&lt;/p>
&lt;p>First, we will install &lt;code>mosquitto&lt;/code> as our MQTT server of choice:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo apt install mosquitto
&lt;/code>&lt;/pre>&lt;p>Now we will add the initial configuration:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo cat /etc/mosquitto.conf
# 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
allow_anonymous false
listener 1883 0.0.0.0
pid_file /run/mosquitto/mosquitto.pid
persistence true
persistence_file mosquitto.db
persistence_location /var/lib/mosquitto/
# Uncomment for logging
# log_dest file /var/log/mosquitto/mosquitto.log
# log_type all
include_dir /etc/mosquitto/conf.d
password_file /etc/mosquitto/pwfile
&lt;/code>&lt;/pre>&lt;p>Now we will generate a password for the &lt;code>phillymesh&lt;/code> user to authenticate with:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo touch /etc/mosquitto/pwfile
$ sudo mosquitto_passwd -c /etc/mosquitto/pwfile phillymesh
&lt;/code>&lt;/pre>&lt;h2 id="adding-bridges" >Adding Bridges
&lt;span>
&lt;a href="#adding-bridges" title="Direct Link to Adding Bridges">
&lt;svg viewBox="0 0 28 23" height="100%" width="19" alt="" xmlns="http://www.w3.org/2000/svg">&lt;path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;/svg>
&lt;/a>
&lt;/span>
&lt;/h2>
&lt;p>Additional configuration can be added to &lt;code>/etc/mosquitto/conf.d/&lt;/code>, so let&amp;rsquo;s create a file for each of our bridges:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo cat /etc/mosquitto/conf.d/mqtt.meshtastic.org.conf
connection mqtt_meshtastic.org
address mqtt.meshtastic.org:1883
# Username and password for the upstream server
remote_username meshdev
remote_password large4cats
# MQTT version to use
bridge_protocol_version mqttv311
# Forward all traffic from msh/*/2/map/ to the remote server
topic msh/+/2/map/# out 0
topic msh/# out 0
# Enable encryption
use_identity_as_username false
bridge_insecure true
# Bridge settings to manage the connection
cleansession true
notifications false
start_type automatic
try_private true
restart_timeout 10
&lt;/code>&lt;/pre>&lt;pre tabindex="0">&lt;code>$ sudo cat /etc/mosquitto/conf.d/mqtt.meshtastic.liamcottle.net.conf
connection mqtt_meshtastic_liamcottle_net
address mqtt.meshtastic.liamcottle.net:1883
# Username and password for the upstream server
remote_username uplink
remote_password uplink
# MQTT version to use
bridge_protocol_version mqttv311
# Forward all traffic from msh/*/2/map/ to the remote server
topic msh/+/2/map/# out 0
topic msh/# out 0
# Enable encryption
use_identity_as_username false
bridge_insecure true
# Bridge settings to manage the connection
cleansession true
notifications false
start_type automatic
try_private true
restart_timeout 10
&lt;/code>&lt;/pre>&lt;h2 id="finishing-touches" >Finishing Touches
&lt;span>
&lt;a href="#finishing-touches" title="Direct Link to Finishing Touches">
&lt;svg viewBox="0 0 28 23" height="100%" width="19" alt="" xmlns="http://www.w3.org/2000/svg">&lt;path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;/svg>
&lt;/a>
&lt;/span>
&lt;/h2>
&lt;p>&lt;code>mosquitto&lt;/code> leverages &lt;code>systemd&lt;/code> to run as a service, so let&amp;rsquo;s start it up:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo systemctl enable --now
&lt;/code>&lt;/pre>&lt;p>Make sure that port &lt;code>1883&lt;/code> is open in the firewall for client connections:&lt;/p>
&lt;pre tabindex="0">&lt;code>$ sudo iptables -L | grep 1883
ACCEPT tcp -- anywhere anywhere tcp dpt:1883
&lt;/code>&lt;/pre>&lt;h2 id="client-configuration" >Client Configuration
&lt;span>
&lt;a href="#client-configuration" title="Direct Link to Client Configuration">
&lt;svg viewBox="0 0 28 23" height="100%" width="19" alt="" xmlns="http://www.w3.org/2000/svg">&lt;path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;/svg>
&lt;/a>
&lt;/span>
&lt;/h2>
&lt;p>We will assume that the Meshtastic node is connected to the Internet already via WiFi/ethernet.&lt;/p>
&lt;p>Client configuration can be set as follows for &lt;strong>MQTT&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>MQTT enabled: &lt;em>on&lt;/em>&lt;/li>
&lt;li>Address: IP or FQDN of your server&lt;/li>
&lt;li>Username: Username you defined&lt;/li>
&lt;li>Password: Password you defined&lt;/li>
&lt;li>Encryption enabled: &lt;em>on&lt;/em>&lt;/li>
&lt;li>JSON output enabled: &lt;em>off&lt;/em>&lt;/li>
&lt;li>TLS enabled: &lt;em>off&lt;/em>&lt;/li>
&lt;li>Root topic: &lt;em>msh/country/state&lt;/em> (Needs to be specific for &lt;code>mqtt.meshtastic.org&lt;/code>, for example: &lt;em>msh/US/PA&lt;/em>)&lt;/li>
&lt;li>Proxy to client enabled: &lt;em>off&lt;/em>&lt;/li>
&lt;li>Map Reporting: &lt;em>on&lt;/em>&lt;/li>
&lt;li>Precise location &lt;em>off&lt;/em> and minimum of &lt;em>1194 ft&lt;/em> to comply with &lt;code>mqtt.meshtastic.org&lt;/code>&lt;/li>
&lt;li>Map reporting interval (seconds): &lt;em>900&lt;/em>&lt;/li>
&lt;/ul>
&lt;p>Client configuration can be set as follows for &lt;strong>Channels &amp;gt; LongFast&lt;/strong>:&lt;/p>
&lt;ul>
&lt;li>Uplink enabled: &lt;em>on&lt;/em>&lt;/li>
&lt;li>Downlink enabled: &lt;em>off&lt;/em>&lt;/li>
&lt;li>Position enabled: &lt;em>on&lt;/em>&lt;/li>
&lt;li>Precise location &lt;em>off&lt;/em> and minimum of &lt;em>1194 ft&lt;/em> to comply with &lt;code>mqtt.meshtastic.org&lt;/code>&lt;/li>
&lt;/ul>
&lt;h2 id="sources" >Sources
&lt;span>
&lt;a href="#sources" title="Direct Link to Sources">
&lt;svg viewBox="0 0 28 23" height="100%" width="19" alt="" xmlns="http://www.w3.org/2000/svg">&lt;path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" fill="none" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2"/>&lt;/svg>
&lt;/a>
&lt;/span>
&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://www.reddit.com/r/meshtastic/comments/1f04xdu/is_it_possible_to_connect_to_two_mqtt_servers_at/">https://www.reddit.com/r/meshtastic/comments/1f04xdu/is_it_possible_to_connect_to_two_mqtt_servers_at/&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://cedalo.com/blog/mosquitto-bridge-configuration/#Bridging_multiple_brokers">https://cedalo.com/blog/mosquitto-bridge-configuration/#Bridging_multiple_brokers&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://adrelien.com/blog/how-to-host-your-own-mqtt-for-your-meshtastic-nodes/">https://adrelien.com/blog/how-to-host-your-own-mqtt-for-your-meshtastic-nodes/&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://meshtastic.org/docs/configuration/module/mqtt/#connect-to-the-default-public-server">https://meshtastic.org/docs/configuration/module/mqtt/#connect-to-the-default-public-server&lt;/a>&lt;/li>
&lt;li>&lt;a href="https://www.reddit.com/r/meshtastic/comments/1cneou7/deleted_by_user/">https://www.reddit.com/r/meshtastic/comments/1cneou7/deleted_by_user/&lt;/a>&lt;/li>
&lt;/ul></description></item></channel></rss>