Direct Methods 'Not Found' under load in IoT Hub

Iain White 146 Reputation points
2025-04-01T13:57:45.5933333+00:00

We are performing some load tests to check that our Edge Module is able to process the number of Direct Methods we need it to.

We've been using the azure-iot-hub python module to call the direct methods. The payload is very small and is the same for every call.

Most of the direct methods are handled, but a few get a 'Not Found' response (~10 out of 10000 fail - and they all fail at the same time).

When they works we see:

urllib3.connectionpool - DEBUG - https://<OUR_IOT_HUB>.azure-devices.net:443 "POST /twins/<OUR_EDGE_DEVICE_NAME>/modules/<OUR_MODULE_NAME>/methods?api-version=2021-04-12 HTTP/1.1" 200 27

And when they fail we see:

urllib3.connectionpool - DEBUG - https://<OUR_IOT_HUB>.azure-devices.net:443 "POST /twins/<OUR_EDGE_DEVICE_NAME>/modules/<OUR_MODULE_NAME>/methods?api-version=2021-04-12 HTTP/1.1" 404 348

The module is always deployed so it can't be the module that isn't being found. Network connectivity looks solid and there are no errors in the edge module logs - seems like the failed calls aren't reaching it.

Is there any explanation for why this might be happening. Seems like it is at the Azure side. It doesn't look like throttling because I'd expect a 429 response.

Any suggestions for what might be happening here?

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
1,258 questions
{count} votes

1 answer

Sort by: Most helpful
  1. VSawhney 320 Reputation points Microsoft External Staff
    2025-04-02T05:35:13.08+00:00

    Hello Iain White,

    As you mentioned 10 out 10000 request are failing intermittently. It might be memory failure on local or server machine.
    You may try the following steps:

    1. Retry Logic: Optimize no of retries and delay in between concurrent requests.
    2. Resetting TLS State
    3. Increase TTL time to keep the session connected
    4. Increase timeout param in your code.
    5. Please distribute traffic between multiple devices.

    Ref doc: Understand and invoke direct methods from IoT Hub

    Hope this helps. Please let us know if you need any further assistance.

    Thank you!

    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.