cabrillosa
cabrillosa

Reputation: 155

What is the expected error code returned if the IoTHub device is disabled while still connected?

I would like to know what is the expected error code returned if the IoTHub device is disabled while still connected in the IoTHub. I tested it with the scenario below:

Scenario A:

  1. Device is connected to iothub.
  2. Disable the device in azure iot explorer.
  3. Device was disconnected.

Actual result: Error code received was IOTHUB_CLIENT_CONNECTION_NO_NETWORK

I expect that the error code should be IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED

Scenario B:

  1. Disable the device first in iothub.
  2. Device will attempt the connection. Actual result: error code received was IOTHUB_CLIENT_CONNECTION_DEVICE_DISABLED

Scenario B is expected. How about scenario A?

Thank you very much for your support!

Upvotes: 0

Views: 645

Answers (1)

humblejay
humblejay

Reputation: 347

This seems related to the limited error reporting in MQTT 3.1.1. The server will drop the connection when the device is disabled in IoTHub, it has no implicit mechanism to tell the client why it was disconnected. The client experiences network issue which then gets surfaced.

In the second case once the TCP connection is initiated the server expects CONNECT frame but as the device is disabled the server returns 0x03 which is translated as disabled. The possible errors are again limited as you can see in the specs. http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html section 3.2.2.3

Upvotes: 1

Related Questions