Skip to main content
Version: 2.0-beta.1

PostgreSQLMQTT Integration Guide

Use MaestroHub's MQTT connector to exchange real-time messages with PLC gateways, IoT devices, and event-driven services. This guide explains how to configure connections, design publish/subscribe functions, and orchestrate pipelines.

Overview

The MQTT connector delivers:

  • MQTT v3.1, v3.1.1 and v5.0 support with QoS 0/1/2 and retained message control
  • Publish and subscribe functions for bidirectional communication
  • Security options including TLS, mutual authentication, and username/password logins
  • Payload templating for JSON, binary buffers, or delimited text

Connection Configuration

Creating an MQTT Connection

Navigate to ConnectionsNew ConnectionMQTT and fill in these details:

MQTT Connection Creation Fields

1. Profile Information
FieldDefaultDescription
Profile Name-A descriptive name for this connection profile (required, max 100 characters)
Description-Optional description for this MQTT connection
2. MQTT Broker Configuration
FieldDefaultDescription
Broker URL-MQTT broker endpoint (e.g., mqtt://broker.example.com:1883) – required, must be a valid URL
MQTT Version3.1.1MQTT protocol version (3.1 / 3.1.1 / 5.0) – required
Client ID-Unique client identifier (max 65535 characters). Server generates if not specified
Keep Alive (sec)60Keep alive interval in seconds (0-65535)
Connect Timeout (sec)30Connection timeout in seconds (1-300)

Protocol Options

  • 3.1: Legacy MQTT version
  • 3.1.1: Recommended – most widely supported
  • 5.0: Latest – enhanced features and performance
3. Session Management
3a. For MQTT v3.1 and v3.1.1
FieldDefaultDescription
Clean SessiontrueStart with a clean session on connect
3b. For MQTT v5.0
FieldDefaultDescription
Clean Start-Start with a clean session on initial connection
4. Basic Authentication
FieldDefaultDescription
Username-MQTT broker username (optional)
Password-MQTT broker password (optional, but username is required if password is provided)
5. TLS/SSL Settings
5a. TLS Configuration
FieldDefaultDescription
Enable TLS/SSLfalseUse encrypted connection to the MQTT broker
Skip Certificate VerificationfalseSkip SSL certificate verification (not recommended for production)
5b. Certificate Verification Settings

(Only displayed when TLS is enabled and Certificate Verification is NOT skipped)

FieldDefaultDescription
Server Name (SNI)-Server name for SNI verification (e.g., broker.example.com)
TLS Version-Minimum TLS version (1.0 / 1.1 / 1.2 / 1.3)
5c. Client Certificates

(Only displayed when TLS is enabled and Certificate Verification is NOT skipped)

FieldDefaultDescription
Client Certificate-Client certificate for mutual TLS authentication (PEM format)
Private Key-Private key for client certificate (PEM format)
CA Certificate-CA certificate for server verification (PEM format)
6. Last Will and Testament (LWT)
FieldDefaultDescription
Will Topic-Topic to publish the will message (e.g., clients/disconnected)
Will QoS0Quality of Service for will message (0 / 1 / 2)
Will Message-Message to publish on unexpected disconnect
Retain Will MessagefalseBroker retains the last will message

QoS Levels

  • QoS 0: At most once – no confirmation
  • QoS 1: At least once – confirmed delivery
  • QoS 2: Exactly once – guaranteed single delivery
7. MQTT v3.1.1 Advanced Options

(Only displayed when MQTT Version = 3.1 or 3.1.1)

7a. Connection Timing
FieldDefaultDescription
Ping Timeout (seconds)-Timeout for ping requests (1-300, leave empty for library default)
Write Timeout (seconds)-Timeout for write operations (1-300, leave empty for library default)
Max Reconnect Interval (seconds)-Maximum interval between reconnect attempts (1-3600, leave empty for library default)
7b. Connection Behavior
FieldDefaultDescription
Auto ReconnectfalseAutomatically reconnect when connection is lost
Connect RetryfalseRetry connection attempts on failure
Resume SubscriptionsfalseAutomatically resume subscriptions on reconnect
Order MattersfalsePreserve message ordering
Disable Auto ACKfalseDisable automatic message acknowledgment
7c. Message Handling
FieldDefaultDescription
Connect Retry Interval (seconds)-Interval between connection retry attempts (1-300, leave empty for library default)
Max Resume Pub In Flight-Maximum publish messages in flight during resume (0-65535, leave empty for library default)
8. MQTT v5.0 Enhanced Properties

(Only displayed when MQTT Version = 5.0)

8a. Session & Flow Control
FieldDefaultDescription
Session Expiry Interval (seconds)-How long session state persists after disconnect (0-4294967295, 0 = immediately expire)
Receive Maximum-Maximum number of QoS 1 and QoS 2 messages that can be outstanding (1-65535, 65535 = unlimited)
Maximum Packet Size (bytes)-Maximum size of MQTT packets that can be received (1-268435455, 268435455 = 256MB)
8b. Topic Aliases & Information
FieldDefaultDescription
Topic Alias Maximum-Maximum topic aliases for reducing topic name overhead (0-65535, 0 = no aliases)
Request Response InformationfalseRequest enhanced response information from broker
Request Problem InformationfalseRequest detailed error information from broker
Packet Timeout (seconds)-Timeout for packet operations (1-300, leave empty for library default)
8c. Manual Acknowledgment
FieldDefaultDescription
Enable Manual AcknowledgmentfalseManually control message acknowledgments
Send ACKs Interval (ms)-Interval between sending acknowledgments (1-10000 ms, leave empty for library default)
8d. User Properties
FieldDefaultDescription
User Properties-Custom key-value pairs for application-specific metadata (JSON format)

Example User Properties

  • {"correlationId":"12345","origin":"edge-gateway"} – Identify related transactions
  • {"tenant":"alpha","priority":"high"} – Route messages by tenant or priority
9. Connection Labels
FieldDefaultDescription
Labels-Key-value pairs to categorize and organize this MQTT connection (max 10 labels)

Example Labels

  • environment: production – Deployment environment
  • team: iot – Responsible team
  • protocol: mqtt – Connection protocol
  • region: us-east-1 – Geographical region
Notes
  • MQTT Version compatibility: Sections 7 (v3.1.1 Advanced Options) and 8 (v5.0 Enhanced Properties) appear based on the selected MQTT version.
  • Broker URL protocol detection automatically enables TLS when using mqtts://, ssl://, or wss:// schemes.
  • Authentication requires a username when a password is provided.
  • TLS certificate fields are available only when TLS is enabled and certificate verification is not skipped.
  • Clean Session and Clean Start represent the same behavior in v3.1.1 and v5.0, respectively.
  • Fields marked as "leave empty for library default" fall back to the MQTT library defaults.
  • Timeout values are in seconds unless noted (Send ACKs Interval uses milliseconds).

Function Builder

Creating MQTT Functions

After the connection is configured:

  1. Go to FunctionsNew Function
  2. Choose MQTT Publish or MQTT Subscribe as the function type
  3. Select the MQTT connection profile
  4. Define topic filters, QoS, retained settings, and payload templates
MQTT Function Creation

Design MQTT publish or subscribe functions with topic templates and payload mappings

Publish Function

Purpose: Send messages to MQTT topics. Create a function to publish messages to specific MQTT topics with configurable payload templates, QoS levels, and retention settings.

Configuration Fields

FieldTypeRequiredDefaultDescription
Topic TemplateStringYes-MQTT topic to publish to (supports parameters). Example: sensors/((deviceId))/temperature
Payload TemplateStringYes-Message payload template (supports parameters). Example: {"temperature": ((value)), "timestamp": "((now))"}
QoS LevelNumberNo0Quality of Service level for published messages (0, 1, or 2)
RetainedBooleanNofalseWhether messages should be retained by the broker
Wait for Acknowledgment (v3.1.1)BooleanNotrueWait for publish acknowledgment from broker (MQTT v3.1.1)
Duplicate Detection (v3.1.1)BooleanNofalseEnable duplicate message detection (MQTT v3.1.1)
Content Type (v5.0)StringNo-MIME type of the message payload (MQTT v5.0). Example: application/json
Message Expiry (v5.0)NumberNo-Message expiry interval in seconds (1-4294967295) (MQTT v5.0)
Payload Format (v5.0)NumberNo-Payload format indicator: 0=bytes, 1=UTF-8 (MQTT v5.0)
Response Topic (v5.0)StringNo-Topic for response messages (MQTT v5.0)
Correlation Data (v5.0)StringNo-Request correlation identifier (MQTT v5.0)
Topic Alias (v5.0)NumberNo-Topic alias for compression (1-65535) (MQTT v5.0)
User Properties (v5.0)ObjectNo-Custom key-value properties for the message (MQTT v5.0)

Use Cases: Sensor data publishing, device command sending, status updates, event notifications

Subscribe Function

Purpose: Receive messages from MQTT topics. Create a function to listen for messages from specific MQTT topics with wildcard support for flexible topic matching.

Configuration Fields

FieldTypeRequiredDefaultDescription
Topic FiltersArrayYes["sensors/+/data"]MQTT topic patterns to subscribe to (supports wildcards + and #). Example: ["sensors/+/temperature", "devices/+/status"]
Single Topic FilterStringNo-Single MQTT topic pattern (alternative to topics array)
QoS LevelNumberNo0Quality of Service level for subscription (0, 1, or 2)
No Local (v5.0)BooleanNofalseDon't receive messages published by this client (MQTT v5.0)
Retain as Published (v5.0)BooleanNofalsePreserve the original retain flag of messages (MQTT v5.0)
Retain Handling (v5.0)NumberNo0How to handle retained messages: 0=send, 1=send if new, 2=don't send (MQTT v5.0)
Subscription Identifier (v5.0)NumberNo-Unique identifier for this subscription (1-268435455) (MQTT v5.0)
Shared Subscription Group (v5.0)StringNo-Name for shared subscription group (generates $share/group/topic syntax) (MQTT v5.0)
User Properties (v5.0)ObjectNo-Custom key-value properties for the subscription (MQTT v5.0)

Use Cases: Sensor data collection, device status monitoring, event processing, message routing

Using Parameters

MQTT functions support parameterized topics and payload values via the ((parameterName)) syntax.

ConfigurationDescriptionExample
TypeValidate incoming pipeline datastring, number, boolean, datetime, json, buffer
RequiredForce topic fragments or payload fieldsRequired / Optional
Default ValueProvide fallback values'line-01', 0, '{}'
DescriptionDocument intent for other authors"Line identifier appended to the topic path"
MQTT Function Parameters

Configure parameter validation, defaults, and descriptions for MQTT topics and payloads

Pipeline Integration

Use the MQTT connection functions you create here as nodes inside the Pipeline Designer to synchronize production data with the rest of your stack. Drag in the publish or subscribe node, bind its parameters to upstream node outputs or constants, and shape event-driven flows without leaving the designer.

If you are planning more complex orchestration, review the Connector Nodes page for patterns on where MQTT nodes fit best within broader orchestration strategies.

MQTT node in pipeline designer

MQTT node with connection, function, and parameter mappings

Common Use Cases

Telemetry Distribution

Publish normalized sensor data to MQTT topics consumed by SCADA dashboards, analytics platforms, or digital twins.

Command Handling

Subscribe to command topics from enterprise systems and invoke PLC writes, REST calls, or script nodes in response.

Edge-to-Cloud Bridging

Bridge legacy PLC data into cloud IoT platforms by combining OPC UA/Modbus reads with MQTT publish steps.