MQTT
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish/subscribe-based messaging protocol designed for low-bandwidth, high-latency, or unreliable network environments. It is widely used in IoT, mobile applications, and distributed systems to enable efficient communication between devices. By reducing data transmission volume and simplifying communication processes, it ensures reliable message delivery while supporting multiple Quality of Service (QoS) levels to meet different business needs.
Installation and Configuration¶
- MQTT Broker
TrueWatch supports receiving MQTT protocol data through Func.
Install Func¶
It is recommended to activate TrueWatch integration - extensions - DataFlux Func (Automata): all prerequisites are automatically installed. Please proceed with the script installation.
If you are deploying Func yourself, refer to Self-deploying Func
It is recommended to deploy the GSE version.
FUNC has already implemented the integration with MQTT data sources. Follow the steps below to connect:
- 1 Write the script
Write a script on Func to consume MQTT data.
import json
@DFF.API('Message Handler')
def message_handler(topic, message):
print(f"Received message: {message} on topic {topic}")
After writing the script, click the 【Publish】 button.
- 2 Configure the MQTT connector
① Select the type as MQTT Broker (v5.0)
② Fill in the ID, host, and port.
③ Topic and the corresponding script for topic consumption.
④ Click to test connectivity to ensure MQTT can connect normally.
⑤ Click save to complete.