TL;DR MQTT uses port 1883
for unsecure communication and port 8883
for secure communication. Port 1883
is active by default, just make sure to activate 8883
in your ejabberd
configuration and you’re good to go.
We live in a very dense metropolitan city and getting around / commuting is not really for the faint-hearted. However, I’ve been trying to support my 10 year old to start going to school on his own. It’s a 20 min. walk but he has to carefully cross a couple of streets, have an eye out for the traffic and move through some dense crowd. Childhood here and now, isn’t like it was for us.
Knowing the risks but also to promote his self-confidence, I’ve convinced him to walk every morning on his own. We’re both a little timid so I have been placing some safety measures to make it easier easier for the both of us (i.e. I kindly asked a teacher / friend from school to make sure he’s there in the morning, arranged a classmate in the neighbourhood so he had a buddy to meet and walk together). However, I also wanted to put an old phone with GPS in his school-bag so I could also see that he reaches his destination without any problems. Thankfully, the school is a “no phone” zone, so all the kids handover any phones they may have with them to the security at entrance.
There are a ton of services out there that makes location sharing a breeze. However, hardly any of them are free-software. Digging around I discovered a nice little FOSS app called Owntracks. The idea is that this app sends location data in JSON format to an “MQTT Broker” (server), and the server publishes it to other registered users. The same app allows you to see all registered user locations being published. So it can easily be used as a nice “real-time” location sharing app for the family / close friends.
To my surprise, I learnt that the ejabberd
software (bundled with FBX) is also an MQTT Broker. Already a fan of XMPP, this came to me as great news, feeling the joy of having discovered an easter egg on my home server. I’m sharing the steps to activate the MQTT potential of your ejabberd
software below. The reference information can be found here. Owntracks was straightforward to setup, so I’m not getting on any details here – just be careful about making sure to use TLS - but feel free to ask.
-
If you’re using a router make sure to forward ports
1883
and8883
to your FBX. -
On your FBX firewall, allow connection to ports
1883
and8883
. You can easily do this withCockpit Network Settings
as these ports are already pre-labed for MQTT. -
In your
/etc/ejabberd/ejabberd.yml
file, add the following:
listen:
- port: 5280
ip: "::"
module: ejabberd_http
tls: false
protocol_options: 'TLS_OPTIONS'
request_handlers:
/admin: ejabberd_web_admin
/.well-known/acme-challenge: ejabberd_acme
/mqtt: mod_mqtt
- port: 1883
ip: "::"
module: mod_mqtt
backlog: 1000
- port: 8883
ip: "::"
module: mod_mqtt
backlog: 1000
tls: true
…
modules:
mod_mqtt: {}
Restart your ejabberd service and you should now (hopefully) be able to communicate through MQTT with your FBX credentials.
Good Luck.
I found MQTT has a lot of other use-cases, especially for IoT.