diff --git a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-mqtt.md b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-mqtt.md index 11e353f01..fa489b0fe 100644 --- a/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-mqtt.md +++ b/daprdocs/content/en/reference/components-reference/supported-pubsub/setup-mqtt.md @@ -28,7 +28,7 @@ spec: - name: retain value: "false" - name: cleanSession - value: "true" + value: "false" - name: backOffMaxRetries value: "0" ``` @@ -43,9 +43,9 @@ The above example uses secrets as plain strings. It is recommended to use a secr |--------------------|:--------:|---------|---------| | url | Y | Address of the MQTT broker. Can be `secretKeyRef` to use a secret reference.
Use the **`tcp://`** URI scheme for non-TLS communication.
Use the **`ssl://`** URI scheme for TLS communication. | `"tcp://[username][:password]@host.domain[:port]"` | consumerID | N | The client ID used to connect to the MQTT broker. Defaults to the Dapr app ID. | `"myMqttClientApp"` -| qos | N | Indicates the Quality of Service Level (QoS) of the message. Defaults to `0`. |`1` +| qos | N | Indicates the Quality of Service Level (QoS) of the message ([more info](https://www.hivemq.com/blog/mqtt-essentials-part-6-mqtt-quality-of-service-levels/)). Defaults to `1`. |`0`, `1`, `2` | retain | N | Defines whether the message is saved by the broker as the last known good value for a specified topic. Defaults to `"false"`. | `"true"`, `"false"` -| cleanSession | N | Sets the `clean_session` flag in the connection message to the MQTT broker if `"true"`. Defaults to `"true"`. | `"true"`, `"false"` +| cleanSession | N | Sets the `clean_session` flag in the connection message to the MQTT broker if `"true"` ([more info](http://www.steves-internet-guide.com/mqtt-clean-sessions-example/)). Defaults to `"false"`. | `"true"`, `"false"` | caCert | Required for using TLS | Certificate Authority (CA) certificate in PEM format for verifying server TLS certificates. | `"-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----"` | clientCert | Required for using TLS | TLS client certificate in PEM format. Must be used with `clientKey`. | `"-----BEGIN CERTIFICATE-----\n\n-----END CERTIFICATE-----"` | clientKey | Required for using TLS | TLS client key in PEM format. Must be used with `clientCert`. Can be `secretKeyRef` to use a secret reference. | `"-----BEGIN RSA PRIVATE KEY-----\n\n-----END RSA PRIVATE KEY-----"` @@ -112,7 +112,7 @@ spec: - name: retain value: "false" - name: cleanSession - value: "false" + value: "true" - name: backoffMaxRetries value: "0" ``` @@ -121,6 +121,8 @@ spec: The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here]({{< ref component-secrets.md >}}). {{% /alert %}} +Note that in the case, the value of the consumer ID is random every time Dapr restarts, so we are setting `cleanSession` to true as well. + ## Create a MQTT broker {{< tabs "Self-Hosted" "Kubernetes">}} @@ -129,7 +131,7 @@ The above example uses secrets as plain strings. It is recommended to use a secr You can run a MQTT broker [locally using Docker](https://hub.docker.com/_/eclipse-mosquitto): ```bash -docker run -d -p 1883:1883 -p 9001:9001 --name mqtt eclipse-mosquitto:1.6.9 +docker run -d -p 1883:1883 -p 9001:9001 --name mqtt eclipse-mosquitto:1.6 ``` You can then interact with the server using the client port: `mqtt://localhost:1883` @@ -157,7 +159,7 @@ spec: spec: containers: - name: mqtt - image: eclipse-mosquitto:1.6.9 + image: eclipse-mosquitto:1.6 imagePullPolicy: IfNotPresent ports: - name: default