MQTT Protocol Data Ingestion
Lightweight messaging protocol ideal for resource-constrained devices and real-time data streaming with CivIoT.
Overview
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe messaging protocol designed for IoT devices with limited bandwidth and processing power. It's perfect for battery-powered sensors, remote monitoring systems, and real-time data collection scenarios.
CivIoT's MQTT broker supports QoS levels, TLS encryption, and provides reliable message delivery with automatic reconnection handling for unstable network conditions.
MQTT Broker Configuration
• Supports both MQTT v3.1.1 and v5.0 protocols
• TLS encryption available for secure connections
• Automatic reconnection with exponential backoff
• Device-specific credentials for secure access
• Client ID must be unique across all devices
• Automatic token refresh support
Topic Structure
data: Sensor readings and device measurements
status: Device health and operational status
config: Configuration updates and commands
Message Format
Required fields: timestamp, device_id, sensors
Optional fields: location, metadata
Message size: Keep messages under 256KB for optimal performance
Quality of Service (QoS) Levels
• Lowest overhead
• No guarantee of delivery
• Best for non-critical data
• Reliable delivery
• Possible duplicates
• Good for most IoT use cases
• Guaranteed delivery
• No duplicates
• Critical data applications
Code Examples
Best Practices
Use Appropriate QoS Levels
Choose QoS 1 for most IoT data and QoS 2 only for critical information that cannot tolerate duplicates.
Implement Reconnection Logic
Handle network disconnections gracefully with exponential backoff and automatic reconnection.
Keep Messages Small
Limit message size to improve transmission reliability and reduce bandwidth usage.
Use TLS for Security
Enable TLS encryption when transmitting sensitive data over public networks.
Performance & Limits
Troubleshooting
Connection Refused
Check broker URL, port, and firewall settings. Ensure credentials are correct.
Authentication Failed
Verify username/password and ensure device is properly registered in CivIoT.
Message Not Received
Check topic structure, QoS settings, and ensure client is subscribed to the correct topic.
Frequent Disconnections
Increase keep-alive interval and implement proper reconnection logic.
Need Help with MQTT Integration?
If you encounter any issues with MQTT data ingestion or need assistance with your integration, our support team is here to help.
Contact Support