MicrosoftDocs / azure-docs

Open source documentation of Microsoft Azure
https://docs.microsoft.com/azure
Creative Commons Attribution 4.0 International
10.31k stars 21.5k forks source link

Need clarification on the statement "DPS doesn't support persistent sessions" #117267

Closed LeelaRajesh-Sayana closed 12 months ago

LeelaRajesh-Sayana commented 1 year ago

Under the section Use MQTT protocol directly as a device, there is a statement which states, "DPS doesn't support persistent sessions"

Customer observed that for the devices connected to Azure using DPS, the session is persisted even when device has been disconnected for more than a week. when connecting to Azure the "Session Present" property indicates as equal to true (MQTT » CONNACK » Session Present).

Here are logs captured for the device before connecting to Azure D (2023-11-15T18:36:38Z) DPS: Provisioning API Version: 1.3.4 D (2023-11-15T18:36:38Z) DPS: Iothub API Version: 1.3.4 D (2023-11-15T18:36:38Z) DPS: DPS task is waiting activation I (2023-11-15T18:36:39Z) DPS: Initiating connection to IoTHub via DPS I (2023-11-15T18:36:40Z) DPS: Registering Device .... I (2023-11-15T18:36:45Z) DPS: Provisioning Status: PROV_DEVICE_REG_STATUS_CONNECTED I (2023-11-15T18:36:46Z) DPS: Provisioning Status: PROV_DEVICE_REG_STATUS_ASSIGNING I (2023-11-15T18:36:50Z) DPS: Registration Information received from service: XXXXX.azure-devices.net, XXXXX I (2023-11-15T18:36:50Z) DPS: Registered successfully! I (2023-11-15T18:36:50Z) DPS: Working with IoT Central. V (2023-11-15T18:36:54Z) azure: -> 13:36:54 CONNECT | VER: 4 | KEEPALIVE: 20 | FLAGS: 128 | USERNAME: XXXXX.azure-devices.net/XXXXX/?api-version=2017-11-08-preview&DeviceClientType=iothubclient%2f1.3.4%20(native%3b%20freertos%3b%20esp%20platform) | CLEAN: 0 V (2023-11-15T18:36:56Z) azure: <- 13:36:56 CONNACK | SESSION_PRESENT: true | RETURN_CODE: 0x0

Link to customer question on Q&A platform - https://learn.microsoft.com/en-us/answers/questions/1426252/azure-iot-dps-does-dps-support-persistent-sessions


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

Naveenommi-MSFT commented 1 year ago

@LeelaRajesh-Sayana Thanks for your feedback! We will investigate and update as appropriate.

Jesusbar commented 1 year ago

@LeelaRajesh-Sayana based on what I observed on the logs, the session is being persisted by IoT Central, which uses DPS and IoT Hub under it. The DPS session is only used for registering the device to the correct hub and stablish the connection between the device and the IoT Hub, after that it has no role on the communication flow between device and IoT Hub. DPS session are non-persistent and every time the device is assigned to the hub, it will end the session, however the Device<->IoT Hub session will be stablished then. I believe that existing session is the log you are seeing from IoT Central.

You can learn more on this documentation in regards IoT Central persistent connections: https://learn.microsoft.com/en-us/azure/iot-central/core/overview-iot-central-developer#connectivity-patterns

You can also learn more on DPS usage from IoT Central at https://learn.microsoft.com/en-us/azure/iot-central/core/overview-iot-central-developer#provision-a-device

timlt commented 12 months ago

@LeelaRajesh-Sayana does that answer the question on persistent sessions?

LeelaRajesh-Sayana commented 12 months ago

Thank you @Jesusbar for providing clarification around this. This helps.

@timlt I do not have any further questions on this. This issue can be closed. Thank you