Search code examples
azureazure-iot-hubazure-eventgridazure-iot-sdk

Does the device get the error message from IoThub if the eventgrid event delivery fails?


I was wondering if IoThub informs the device if the event grid message fails? Here is the architecture flow:

Device->IoTHub->EventGrid->Webhook

So when the EevntGrid gets some error(like 400/500 error due to some reason), does IoThub inform the device of this failure when the device could retry, or does it send a message received where the device will think the message has been sent successfully to the Webhook? Is there a workflow/ design where we could inform the device of this error?


Solution

  • So when the EevntGrid gets some error(like 400/500 error due to some reason), does IoThub inform the device of this failure when the device could retry, or does it send a message received where the device will think the message has been sent successfully to the Webhook?

    No, it is an asynchronous flow. There won't be any cloud-to-device message that tells the device thing have failed. At least not out-of-the-box. Also, the retry logic is already present in the Event Grid, no need for the device to retry the message unless it fails to communicate with the IoT Hub.

    Is there a workflow/ design where we could inform the device of this error?

    Take this example:

    1. Device sends telemetry
    2. IoT Hub receives message and passes it to Event Grid
    3. Event Grid tries to deliver event
    4. Event delivery fails due to a transient error
    5. Event Grid retries event delivery n times over a given period
    6. Event is succesfully delivered or dead lettered
    7. In case of succesful delivery, the message is processed by the endpoint.

    Now, the cloud-to-device message can only be send at step 6 (or 7 if you want to include the response of the final endpoint). There might be milliseconds between step 1 and 6/7 or there might be minutes, hours or even days (in worst case scenarios, depending on the retry configuration and endpoint status).

    A logical thing is to have the endpoint publish its own event and get it delivered to the cloud device, but this will be an asynchronous flow.

    Why do you want to burden the device with the outcome of the message delivery? I think it shouldn't have to worry about the flow unless it fails to communicate with the IoT Hub.