Azure IOT Hub C2D message was auto rejected when using MQTT

重归 1 Reputation point
2022-09-15T01:16:28.793+00:00

to reproduce the issue:

  1. Register a new device.
  2. Send c2d message to device before the device FIRST connected .This First connection is the key point. Issue will be disappeared after the device first connection.
  3. Device connect IOT hub using MQTT , issue won't be reproduced by AMQP or HTTPS.
Azure IoT
Azure IoT
A category of Azure services for internet of things devices.
399 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. QuantumCache 20,266 Reputation points
    2022-09-15T04:01:10.193+00:00

    Hello @重归 , Thanks for reaching out on this forum.

    Could you please add more info on the issue.

    1) Which Region you have created Azure IoT Hub
    2) Azure IoT Hub Tier?
    3) How did you make the MQTT connection, any specific client used?
    4) Any screenshots of the error or the logs would be more helpful to help you further....
    5) Any log traces?

    Thanks for understanding

    Other workarounds from similar issues which may be helpful in this scenario:

    setting the Clean Session flag to ‘0’ and QoS=1 which prevents losing messages when the device is in a disconnected state.

    https://video2.skills-academy.com/en-us/azure/iot-hub/iot-hub-mqtt-support#receiving-cloud-to-device-messages

    The device does not receive any messages from IoT Hub until it has successfully subscribed to its device-specific endpoint, represented by the devices/{device_id}/messages/devicebound/# topic filter. After a subscription has been established, the device receives cloud-to-device messages that were sent to it after the time of the subscription. If the device connects with CleanSession flag set to 0, the subscription is persisted across different sessions. In this case, the next time the device connects with CleanSession 0 it receives any outstanding messages sent to it while disconnected. If the device uses CleanSession flag set to 1 though, it does not receive any messages from IoT Hub until it subscribes to its device-endpoint.

    If you try to do lot of connect/disconnects at same time for n number of devices, then there will be throttling. Numbers are in below link

    https://video2.skills-academy.com/en-us/azure/iot-hub/iot-hub-devguide-quotas-throttling

    247275-image.png

    But you can always avoid throttling by scaling up as per your needs.

    https://azure.microsoft.com/en-us/blog/iot-hub-throttling-and-you/

    1 person found this answer helpful.
    0 comments No comments

  2. Anton Bastiuchenko 0 Reputation points
    2023-06-29T13:43:23.7633333+00:00

    If I use MQTT protocol and .NET SDK on device side, my c2d messages are rejected. I described this issue here - https://github.com/MicrosoftDocs/azure-docs/issues/98930#issuecomment-1596319291

    1. I want to understand is it a bug in Azure IoT Hub or in Azure IoT SDK .NET or in MQTTNet (that is used in Azure IoT .NET SDK).
    2. Is it possible to update Azure IoT Hub Features to GWV2 somehow from my side?
    3. Should I share with you any other information to shed light on the situation? Maybe somehow export schema of IoT Hub and share with you?
    4. Why newly created Azure IoT Hub still use GWv1 if you are already upgrading all existing Azure IoT Hub to GWv2 as I understood?
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.