> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/mqtt/receive.md).

# Receive

Task version: 1.1.0

Required Frends version: 5.7+

Required .NET version: 8.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.MQTT/tree/main/Frends.MQTT.Receive>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Host : `String`                     | <p>The address of the MQTT broker.</p><p><br>Default: <code>-</code><br>Example: <code>broker\_host</code></p>                                                                                                                                                                                                                                                                                                                                            |
| BrokerPort : `Int32`                | <p>The port of the MQTT broker.</p><p><br>Default: <code>-</code><br>Example: <code>1883</code></p>                                                                                                                                                                                                                                                                                                                                                       |
| ReceivingTime : `Int32`             | <p>Specifies how many seconds the task (client) will live and process messages.</p><p><br>Default: <code>-</code><br>Example: <code>10</code></p>                                                                                                                                                                                                                                                                                                         |
| ClientId : `String`                 | <p>The client (session) identificator. This will allow to collect messages from an existing session</p><p><br>Default: <code>-</code><br>Example: <code>3fa85f64-5717-4562-b3fc-2c963f66afa6</code></p>                                                                                                                                                                                                                                                   |
| Topic : `String`                    | <p>The topic the client subscribes to when connecting.</p><p><br>Default: <code>-</code><br>Example: <code>example topic</code></p>                                                                                                                                                                                                                                                                                                                       |
| UseTls12 : `Boolean`                | <p>Whether to use TLS authentication.</p><p><br>Default: <code>-</code><br>Example: <code>false</code></p>                                                                                                                                                                                                                                                                                                                                                |
| QoS : `QoS`                         | <p>The Quality of Service (QoS) level for the MQTT session.</p><p>Possible values:</p><ul><li><code>AtMostOnce</code>: The Quality of Service (QoS) level for the MQTT session.</li><li><code>AtLeastOnce</code>: The Quality of Service (QoS) level for the MQTT session.</li><li><code>ExactlyOnce</code>: The Quality of Service (QoS) level for the MQTT session.</li></ul><p><br>Default: <code>-</code><br>Example: <code>QoS.AtMostOnce</code></p> |
| Username : `String`                 | <p>Username for authentication.</p><p><br>Default: <code>-</code><br>Example: <code>testuser</code></p>                                                                                                                                                                                                                                                                                                                                                   |
| 🗝Password : `String`               | <p>Password for authentication.</p><p><br>Default: <code>-</code><br>Example: <code>Password123</code></p>                                                                                                                                                                                                                                                                                                                                                |
| AllowInvalidCertificate : `Boolean` | <p>When true, allows connections even if the server's TLS certificate is invalid (e.g., self-signed,</p><p>expired, or hostname mismatch). WARNING: This reduces security and should only be used in</p><p>development/testing environments or when connecting to internal servers with self-signed certificates.</p><p><br>Default: <code>-</code><br>Example: <code>true</code></p>                                                                     |
| {% endtab %}                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                           |

{% tab title="Options" %}

| Name                             | Description                                                                                                                                          |
| -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| ThrowErrorOnFailure : `Boolean`  | <p>Whether to throw an error on failure.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                      |
| ErrorMessageOnFailure : `String` | <p>Overrides the error message on failure.</p><p><br>Default: <code>-</code><br>Example: <code>MQTT connection failed: broker unreachable</code></p> |
| {% endtab %}                     |                                                                                                                                                      |
| {% endtabs %}                    |                                                                                                                                                      |

## Task Result

| Name                                     | Description                                                                                                                                                                                                                            |
| ---------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Success : `Boolean`                      | <p>Whether connection to the MQTT broker was successful or not.<br>Example: <code>true</code></p>                                                                                                                                      |
| Error : `String`                         | <p>Error(s) if connecting to broker failed. Returns an empty string if no errors exist.<br>Example: <code>Connection refused</code></p>                                                                                                |
| MessagesList : `ConcurrentQueue<String>` | <p>All messages received from the broker in this session.<br>Example: <code>\["message1", "message2"]</code></p>                                                                                                                       |
| CurrentClientId : `String`               | <p>The MQTT client ID. Used to restore a previously opened session to receive buffered messages. When making a new connection, pass it to receive buffered messages.<br>Example: <code>3fa85f64-5717-4562-b3fc-2c963f66afa6</code></p> |

## Task Changelog

Changelog for Task Frends.MQTT.Receive.

### \[1.1.0] - 2026-08-17

#### Added

* Added an `Options` parameter to control error handling: use `ThrowErrorOnFailure` to throw on failure, or set it to `false` to receive the error details in the result instead.

### \[1.0.0] - 2025-04-07

#### Added

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.frends.com/tasks/tasks/mqtt/receive.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
