MQTT
Remote management and monitoring of your kiosk device
Tip
New to MQTT? see the resources below:
To understand MQTT's publish and subscribe architecture, refer to
1. Introduction
Message Queueing Telemetry Transport (MQTT) is a lightweight messaging protocol for devices with limited resources. MQTT is built on top of TCP/IP and is ideal for machine-to-machine communication and the Internet of Things (IoT).
Webview Kiosk utilises the MQTT protocol to enable you to remotely:
- receive events
- update app settings
- perform actions via commands
- request information
2. MQTT Broker
To communicate with Webview Kiosk, you will need an MQTT Broker. The broker acts as an intermediary entity (central hub) that routes messages between devices and applications.
Our recommendation for open source, self-hostable brokers (server) and clients (to send messages to Webview Kiosk) are:
- EMQX and MQTTX (or MQTTX Web)
- Eclipse Mosquitto and Home Assistant - see the Integration Guide
There are also public brokers you can use for testing purposes, such as
- HiveMQ: https://www.mqtt-dashboard.com
- Mosquitto: https://test.mosquitto.org
- EMQX: https://www.emqx.com/en/mqtt/public-mqtt5-broker
3. Global Variables
The following variables will be string-interpolated for supported settings, such as topic names and will payload:
| Variable Name | Description |
|---|---|
| APP_INSTANCE_ID | Unique identifier for the app instance. |
| USERNAME | MQTT username used for authentication. |
To use variables in your settings, use the syntax ${YOUR_VARIABLE}, e.g.
wk/${USERNAME}/${APP_INSTANCE_ID}/commandwhich may evaluate to a string such as
wk/kiosk_user_01/b8378168-ca69-11f0-af20-5a93ec0e6f90/commandSome settings will support additional variables.
5. Debug Logs
MQTT operations are recorded in the debug logs, which can be accessed from any MQTT settings screens. This includes:
- connecting/connected/disconnect
- subscribes
- messages received or published
- errors
A maximum of 100 messages will be stored for the duration of the app activity lifecycle. The logs will not persist between app restarts.
5. Settings
5.1. Enabled
Set to true to allow connections to your configured broker in MQTT -> Connections.
If you are currently in a disconnected state, you will need to manually click
the Connect button after enabling this option (or simply restart the app).
Updated MQTT settings do not get applied immediately if you are already connected. Instead, you will need to reconnect by:
- clicking the restart button in MQTT settings
- manually restarting the application
- send a
Reconnectcommand
Default: false
5.2. Use Foreground Service
Start a Foreground Service to keep the MQTT connection alive.
This will maintain the connection even when Webview Kiosk goes to the background (e.g. another app is opened) or the device screen is turned off (by using PowerManager.PARTIAL_WAKE_LOCK).
Turn on notifications to see the current MQTT status being updated by the foreground service every second.
Also, it is highly recommended that you disable battery optimisation for Webview Kiosk to stop the service from being killed.
For more information, visit:
Default: false
Last updated on