Search code examples
cmqttazure-iot-hub

How to simulate Azure IoT Hub disconnecting


I'm using the paho.mqtt.c library to connect to an Azure IoT Hub. I want to test how my software handles disconnections from the IoT Hub.

How can I simulate the IoT Hub disconnecting the client?

There is no "Stop IoT Hub" button in the Azure Portal -> IoT Hub.


Solution

  • The following are some cases for disconnecting a mqtt device from Azure IoT Hub:

    • connecting a mqtt device with the same deviceId
    • publishing on the wrong topic, for instance: abcd
    • Disable a device connection to IoT Hub on the portal
    • using the REST API for disable a device, see my answer here