Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
howto:mqtt [2022/12/12 00:55] – created nelgin | howto:mqtt [2023/10/01 18:43] (current) – Add firewall note Ree | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
+ | |||
+ | ===== Setup ===== | ||
This is a bit of a stub for MQTT but it'll help you get going, on Ubuntu at least. | This is a bit of a stub for MQTT but it'll help you get going, on Ubuntu at least. | ||
Line 6: | Line 9: | ||
Once compiled and installed, run scfg, make some small change and then save. This will now add a mqtt section to main.ini. Change the host and port (default to 127.0.0.1 port 1883) | Once compiled and installed, run scfg, make some small change and then save. This will now add a mqtt section to main.ini. Change the host and port (default to 127.0.0.1 port 1883) | ||
- | apt install mosquitto mosquitto-clients | + | |
Additionally, | Additionally, | ||
Line 12: | Line 15: | ||
Mosquitto will install and start automatically but you won't see any messages. If you wish to see them, then stop the broker | Mosquitto will install and start automatically but you won't see any messages. If you wish to see them, then stop the broker | ||
- | # systemctl stop mosquitto | + | |
and run it manually | and run it manually | ||
- | # mosquitto -v | + | |
+ | |||
+ | To continue running as a service CTRL-C to stop mosquitto and then restart | ||
+ | |||
+ | sudo systemctl start mosquitto | ||
+ | |||
+ | |||
+ | At this point you should probably rebuild sbbs so that libmosquitto will be picked up and included in libsbbs.so. You can verify this with the following command: | ||
+ | |||
+ | | ||
+ | libmosquitto.so.1 => / | ||
+ | |||
+ | If there is no response to the command, then a recompile is necessary. | ||
Now start sbbs and you should see the following lines in your log | Now start sbbs and you should see the following lines in your log | ||
Line 23: | Line 39: | ||
Dec 12 02:13:08 bbs synchronet: MQTT lib: mosquitto 1.6.9 | Dec 12 02:13:08 bbs synchronet: MQTT lib: mosquitto 1.6.9 | ||
Dec 12 02:13:08 bbs synchronet: MQTT connecting to broker 127.0.0.1: | Dec 12 02:13:08 bbs synchronet: MQTT connecting to broker 127.0.0.1: | ||
- | + | ||
- | + | ||
If you see a " | If you see a " | ||
At this point you should see messages from sbbs being passed into the Mosquitto broker | At this point you should see messages from sbbs being passed into the Mosquitto broker | ||
+ | ``` | ||
1670834270: Received PUBLISH from auto-FEB8177A-5A3E-5EE9-6AA3-9CE9BE593CA3 (d0, q0, r0, m0, ' | 1670834270: Received PUBLISH from auto-FEB8177A-5A3E-5EE9-6AA3-9CE9BE593CA3 (d0, q0, r0, m0, ' | ||
1670834270: Received PUBLISH from auto-FEB8177A-5A3E-5EE9-6AA3-9CE9BE593CA3 (d0, q0, r0, m0, ' | 1670834270: Received PUBLISH from auto-FEB8177A-5A3E-5EE9-6AA3-9CE9BE593CA3 (d0, q0, r0, m0, ' | ||
+ | ``` | ||
Now, to install a client to view the messages. | Now, to install a client to view the messages. | ||
- | wget https:// | + | wget https:// |
then | then | ||
+ | dpkg -i v1.9.0/ | ||
run mqttx to start the package. | run mqttx to start the package. | ||
Line 52: | Line 68: | ||
Now enter the path which will be sbbs/ followed by your BBS's short name, EOTLBBS in my case. You'll find it on your logs. | Now enter the path which will be sbbs/ followed by your BBS's short name, EOTLBBS in my case. You'll find it on your logs. | ||
- | # sbbs/ | + | sbbs/ |
The # at the end like similar to a wildcard and will show you all the messages. | The # at the end like similar to a wildcard and will show you all the messages. | ||
Line 67: | Line 83: | ||
- | dpkg -i v1.9.0/MQTTX_1.9.0_amd64.deb | + | One more tip, if you're starting sbbs from systemd (and why wouldn' |
+ | |||
+ | Changing the sbbs service file " | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | After making changes to your sbbs service file, Be sure to run | ||
+ | |||
+ | sudo systemctl daemon-reload | ||
+ | |||
+ | This is a list of data points captured during a short run. Obviously if you use these, replace your BBS's system name and hostname. | ||
+ | |||
+ | < | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | sbbs/ | ||
+ | </ | ||
+ | |||
+ | Note, the numbers at the end of the log outputs is the log level. These may be subject to change in future and may be added to or removed. | ||
+ | |||
+ | For collecting data and viewing, I highly recommend Node-Red. You can find installation instructions online and should be able to figure its usage but I highly recommend using the current node.js (Node 18 currently) and install the Dashboard module (which will not run on the Ubuntu provided version of node.js). | ||
+ | |||
+ | ===== WebSockets ===== | ||
+ | |||
+ | New browser-based Web Monitor and Node Spy features have been added in 3.20, which are powered by MQTT. The first time you load either of these features you'll be prompted to provide the Hostname and WebSocket Ports for your MQTT server (these are different than the WebSocket ports used to power fTelnet). | ||
+ | |||
+ | Keep in mind that it's your web browser connecting to the MQTT server, so you need to provide a hostname that is reachable by your web browser (ie if your BBS is running on a VPS, then localhost won't be a good choice for the Hostname, unless you plan to remote into that VPS and launch a browser from there). | ||
+ | |||
+ | For the WebSocket ports, you'll need to update your Mosquitto server' | ||
+ | |||
+ | # mqtt protocol standard port | ||
+ | listener 1883 | ||
+ | |||
+ | # mqtt protocol ssl port | ||
+ | listener 8883 | ||
+ | certfile C: | ||
+ | keyfile C: | ||
+ | |||
+ | # websocket protocol standard port | ||
+ | listener 1884 | ||
+ | protocol websockets | ||
+ | socket_domain ipv4 | ||
+ | |||
+ | # websocket protocol ssl port | ||
+ | listener 8884 | ||
+ | protocol websockets | ||
+ | socket_domain ipv4 | ||
+ | certfile C: | ||
+ | keyfile C: | ||
+ | |||
+ | My understanding is that the SSL certs created by the Synchronet Let's Encrypt client can be converted to a format that is usable by Mosquitto, but I haven' | ||
+ | |||
+ | ===== Security ===== | ||
+ | |||
+ | It is VERY important that you DO NOT open any of the MQTT ports to the general public. | ||
===== See Also ===== | ===== See Also ===== | ||
* [[: | * [[: | ||
+ | * [[: | ||
- | {{tag>}} | + | {{tag>mqtt}} |