> For the complete documentation index, see [llms.txt](https://docs.augelab.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.augelab.com/function-blocks/blocks-reference/input-output/communication/mqtt-subscribe-tls-beta.md).

# MQTT Subscribe (TLS-Beta)

This function block connects to an MQTT broker and listens for messages on a chosen topic using TLS (secure) connection options. It receives incoming text payloads and signals when new data has arrived so you can process or forward the data in your scenario.

## 📥 Inputs <a href="#inputs" id="inputs"></a>

`Enable` This boolean input socket controls whether the subscription is active. Set to TRUE to allow receiving messages; FALSE disables processing.

## 📤 Outputs <a href="#outputs" id="outputs"></a>

`Data` Text payload of the most recently received message.

`New Data` Boolean flag that becomes TRUE for a single evaluation when a new message has been received.

## 🕹️ Controls <a href="#controls" id="controls"></a>

`Server / Broker` Enter the MQTT broker address or hostname.

`Port` Set the broker port (common TLS port is 8883).

`Topic` Specify the topic to subscribe to. Incoming messages on this topic appear on the `Data` output.

`Client ID` Optional identifier for this client on the broker.

`Username` Optional username for broker authentication.

`Password` Optional password for broker authentication.

`Use TLS` Toggle to enable secure (TLS) connection mode.

`CA Certificate` Option to provide or reference a CA bundle for TLS certificate verification (the block supports system CA verification).

`Connect` A control to initiate or re-establish the connection with the current settings.

`Auto Reconnect` Toggle to automatically reconnect if the connection is lost.

Note: If the block provides a compact UI, some advanced options may be grouped or under an "Advanced" section.

## 🎯 Features <a href="#features" id="features"></a>

* Secure MQTT subscription with TLS support for encrypted communication.
* Live flagging of new messages via the `New Data` output so you can trigger downstream processing only when necessary.
* Flexible topic selection to subscribe to any valid MQTT topic.
* Connection parameters and basic authentication controls for most broker configurations.
* Graceful reconnect handling so temporary network glitches do not require manual intervention.

## 📝 Usage Instructions <a href="#usage" id="usage"></a>

1. Configure your broker details using the `Server / Broker`, `Port`, and authentication controls if needed.
2. Enter the topic you want to listen to in the `Topic` control.
3. Enable the block by sending TRUE to the `Enable` input or using the block’s UI connect control.
4. Read incoming text payloads from the `Data` output. Use the `New Data` output to trigger downstream blocks only when a fresh message arrives.
5. If you change connection parameters, use the `Connect` control (or toggle `Enable`) to apply them.

## 📊 Evaluation <a href="#evaluation" id="evaluation"></a>

When active, this function block maintains a subscription to the configured topic. On each run it outputs the latest received payload on `Data` and sets `New Data` TRUE only when a new message has arrived since the last evaluation.

## 💡 Tips and Tricks <a href="#tips-and-tricks" id="tips-and-tricks"></a>

* Use `Parse Data Dictionary` or `Data to JSON` after `MQTT Subscribe (TLS-Beta)` to convert incoming JSON text into structured values for further processing.
* If you want to log incoming messages, connect `Data` to `CSV Export` or `Data to JSON` then to an export block.
* Combine with `Debug Input` to print or inspect messages during setup.
* Use `Logic Input` or `Rising Edge` to trigger actions only when `New Data` becomes TRUE.
* For distributed scenarios, pair this block with `Data Write Global` / `Data Read Global` to share the latest message across separate branches of your scenario.
* If the message contains image references or encoded image data, send the decoded image to `Show Image` to preview it.
* When publishing responses or acknowledgements, use the corresponding `MQTT Publish (TLS-Beta)` block to send messages back to the broker.

## 🛠️ Troubleshooting <a href="#troubleshooting" id="troubleshooting"></a>

* Connection fails: Verify `Server / Broker`, `Port`, and network access. Ensure TLS port and firewall rules are correct.
* Authentication errors: Re-check `Username` and `Password` entries, and confirm broker ACLs.
* No messages appearing: Confirm the exact `Topic` string (wildcards and hierarchy matter) and that another client is publishing to it. Use a simple tester client to confirm.
* Unexpected message format: Use `Parse Data Dictionary` or `String Operations` to inspect and normalize payloads.
* TLS issues: If certificate verification fails, ensure the CA certificate bundle is available or use the system CA option. For troubleshooting only, try a non-TLS connection (if broker allows) to isolate the cause.
