You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/iot-hub/iot-hub-devguide-messages-c2d.md
+20-20Lines changed: 20 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
2
title: Understand Azure IoT Hub cloud-to-device messaging | Microsoft Docs
3
-
description: Developer guide - how to use cloud-to-device messaging with IoT Hub. Includes information about the message life cycle, and configuration options.
3
+
description: This developer guide discusses how to use cloud-to-device messaging with your IoT hub. It includes information about the message life cycle and configuration options.
4
4
author: wesmc7777
5
5
manager: philmea
6
6
ms.author: wesmc
@@ -10,37 +10,37 @@ ms.topic: conceptual
10
10
ms.date: 03/15/2018
11
11
---
12
12
13
-
# Send cloud-to-device messages from IoT Hub
13
+
# Send cloud-to-device messages from an IoT hub
14
14
15
15
To send one-way notifications to a device app from your solution back end, send cloud-to-devices messages from your IoT hub to your device. For a discussion of other cloud-to-devices options supported by IoT Hub, see [Cloud-to-device communications guidance](iot-hub-devguide-c2d-guidance.md).
You send cloud-to-device messages through a service-facing endpoint, */messages/devicebound*. A device then receives the messages through a device-specific endpoint, */devices/{deviceId}/messages/devicebound*.
20
20
21
-
To target each cloud-to-device message at a single device, IoT Hub sets the **to** property to */devices/{deviceId}/messages/devicebound*.
21
+
To target each cloud-to-device message at a single device, your IoT hub sets the **to** property to */devices/{deviceId}/messages/devicebound*.
22
22
23
23
Each device queue holds, at most, 50 cloud-to-device messages. To try to send more messages to the same device results in an error.
24
24
25
25
## The cloud-to-device message life cycle
26
26
27
-
To guarantee at-least-once message delivery, IoT Hub persists cloud-to-device messages in per-device queues. Devices must explicitly acknowledge *completion* for IoT Hub to remove them from the queue. This approach guarantees resiliency against connectivity and device failures.
27
+
To guarantee at-least-once message delivery, your IoT hub persists cloud-to-device messages in per-device queues. For the IoT hub to remove the messages from the queue, the devices must explicitly acknowledge *completion*. This approach guarantees resiliency against connectivity and device failures.
28
28
29
-
The life-cycle state graph for a cloud-to-device message in IoT Hub is displayed in the following diagram:
29
+
The life-cycle state graph is displayed in the following diagram:
30
30
31
31

32
32
33
-
When the IoT Hub service sends a message to a device, the service sets the message state to *Enqueued*. When a device wants to *receive* a message, IoT Hub*locks* the message by setting the state to *Invisible*. This state allows other threads on the device to start receiving other messages. When a device thread completes the processing of a message, it notifies IoT Hub by *completing* the message. IoT Hub then sets the state to *Completed*.
33
+
When the IoT hub service sends a message to a device, the service sets the message state to *Enqueued*. When a device wants to *receive* a message, the IoT hub*locks* the message by setting the state to *Invisible*. This state allows other threads on the device to start receiving other messages. When a device thread completes the processing of a message, it notifies the IoT hub by *completing* the message. The IoT hub then sets the state to *Completed*.
34
34
35
35
A device can also:
36
36
37
-
**Reject* the message, which causes IoT Hub to set it to the *Dead lettered* state. Devices that connect over the Message Queuing Telemetry Transport (MQTT) Protocol can't reject cloud-to-device messages.
37
+
**Reject* the message, which causes the IoT hub to set it to the *Dead lettered* state. Devices that connect over the Message Queuing Telemetry Transport (MQTT) Protocol can't reject cloud-to-device messages.
38
38
39
-
**Abandon* the message, which causes IoT Hub to put the message back in the queue, with the state set to *Enqueued*. Devices that connect over the MQTT Protocol can't abandon cloud-to-device messages.
39
+
**Abandon* the message, which causes the IoT hub to put the message back in the queue, with the state set to *Enqueued*. Devices that connect over the MQTT Protocol can't abandon cloud-to-device messages.
40
40
41
-
A thread could fail to process a message without notifying IoT Hub. In this case, messages automatically transition from the *Invisible* state back to the *Enqueued* state after a *visibility* time-out (or *lock* time-out). The default value of this time-out is one minute.
41
+
A thread could fail to process a message without notifying the IoT hub. In this case, messages automatically transition from the *Invisible* state back to the *Enqueued* state after a *visibility* time-out (or *lock* time-out). The default value of this time-out is one minute.
42
42
43
-
The **max delivery count** property on IoT Hub determines the maximum number of times a message can transition between the *Enqueued* and *Invisible* states. After that number of transitions, IoT Hub sets the state of the message to *Dead lettered*. Similarly, IoT Hub sets the state of a message to *Dead lettered* after its expiration time. For more information, see [Time to live](#message-expiration-time-to-live).
43
+
The **max delivery count** property on the IoT hub determines the maximum number of times a message can transition between the *Enqueued* and *Invisible* states. After that number of transitions, the IoT hub sets the state of the message to *Dead lettered*. Similarly, the IoT hub sets the state of a message to *Dead lettered* after its expiration time. For more information, see [Time to live](#message-expiration-time-to-live).
44
44
45
45
The [How to send cloud-to-device messages with IoT Hub](iot-hub-csharp-csharp-c2d.md) article shows you how to send cloud-to-device messages from the cloud and receive them on a device.
46
46
@@ -55,11 +55,11 @@ A device ordinarily completes a cloud-to-device message when the loss of the mes
55
55
Every cloud-to-device message has an expiration time. This time is set by either of the following:
56
56
57
57
* The **ExpiryTimeUtc** property in the service
58
-
* IoT Hub using the default *time to live* that's specified as an IoT Hub property
58
+
*The IoT hub, by using the default *time to live* that's specified as an IoT hub property
59
59
60
60
See [Cloud-to-device configuration options](#cloud-to-device-configuration-options).
61
61
62
-
A common way to take advantage of a message expiration and to avoid sending messages to disconnected devices is to set short *time to live* values. This approach achieves the same result as maintaining the device connection state, but it is more efficient. When you request message acknowledgments, IoT Hub notifies you which devices are:
62
+
A common way to take advantage of a message expiration and to avoid sending messages to disconnected devices is to set short *time to live* values. This approach achieves the same result as maintaining the device connection state, but it is more efficient. When you request message acknowledgments, the IoT hub notifies you which devices are:
63
63
64
64
* Able to receive messages.
65
65
* Are not online or have failed.
@@ -70,14 +70,14 @@ When you send a cloud-to-device message, the service can request the delivery of
| positive | If the cloud-to-device message reaches the *Completed* state, the IoT hub generates a feedback message. |
75
+
| negative | If the cloud-to-device message reaches the *Dead lettered* state, the IoT hub generates a feedback message. |
76
+
| full |The IoT hub generates a feedback message in either case. |
77
77
78
78
If the **Ack** value is *full*, and you don't receive a feedback message, it means that the feedback message has expired. The service can't know what happened to the original message. In practice, a service should ensure that it can process the feedback before it expires. The maximum expiration time is two days, which leaves time to get the service running again if a failure occurs.
79
79
80
-
As explained in [Endpoints](iot-hub-devguide-endpoints.md), IoT Hub delivers feedback through a service-facing endpoint, */messages/servicebound/feedback*, as messages. The semantics for receiving feedback are the same as for cloud-to-device messages. Whenever possible, message feedback is batched in a single message, with the following format:
80
+
As explained in [Endpoints](iot-hub-devguide-endpoints.md), the IoT hub delivers feedback through a service-facing endpoint, */messages/servicebound/feedback*, as messages. The semantics for receiving feedback are the same as for cloud-to-device messages. Whenever possible, message feedback is batched in a single message, with the following format:
81
81
82
82
| Property | Description |
83
83
| ------------ | ----------- |
@@ -91,12 +91,12 @@ The body is a JSON-serialized array of records, each with the following properti
91
91
| ------------------ | ----------- |
92
92
| EnqueuedTimeUtc | A timestamp that indicates when the outcome of the message happened (for example, the hub received the feedback message or the original message expired) |
93
93
| OriginalMessageId | The *MessageId* of the cloud-to-device message to which this feedback information relates |
94
-
| StatusCode | A required string, used in feedback messages that are generated by IoT Hub: <br/> *Success* <br/> *Expired* <br/> *DeliveryCountExceeded* <br/> *Rejected* <br/> *Purged*|
94
+
| StatusCode | A required string, used in feedback messages that are generated by the IoT hub: <br/> *Success* <br/> *Expired* <br/> *DeliveryCountExceeded* <br/> *Rejected* <br/> *Purged*|
95
95
| Description | String values for *StatusCode*|
96
96
| DeviceId | The *DeviceId* of the target device of the cloud-to-device message to which this piece of feedback relates |
97
97
| DeviceGenerationId | The *DeviceGenerationId* of the target device of the cloud-to-device message to which this piece of feedback relates |
98
98
99
-
For the cloud-to-device message to be able to correlate its feedback with the original message, the service must specify a *MessageId*.
99
+
For the cloud-to-device message to correlate its feedback with the original message, the service must specify a *MessageId*.
100
100
101
101
The body of a feedback message is shown in the following code:
102
102
@@ -134,4 +134,4 @@ For more information about how to set these configuration options, see [Create I
134
134
135
135
For information about the SDKs that you can use to receive cloud-to-device messages, see [Azure IoT SDKs](iot-hub-devguide-sdks.md).
136
136
137
-
To try out receiving cloud-to-device messages, see the [Send cloud-to-device](iot-hub-csharp-csharp-c2d.md) tutorial.
137
+
To try out receiving cloud-to-device messages, see the [Send cloud-to-device](iot-hub-csharp-csharp-c2d.md) tutorial.
0 commit comments