简体   繁体   中英

What is the behavior of IoT Hub when the device send telemetry message without registered in IoT Hub?

I seems to cannot get this information anywhere. I would like to know what will happen to the telemetry message if the device that send this message is not registered in IoT Hub.

This is because I found a few messages from an unregistered device in IoT Hub being processed to the built-in event hub and progress to my next Function App after the built-in event hub.

Thus, I would like to know how is the behavior of IoT Hub if the message was sent without the device registered under the IoT Hub.

Thank you.

This is a really excellent question because it depends on how you connect to the IoT Hub. For my answer, I will take into account MQTT, AMQP, and HTTP. When you connect to an IoT Hub with a device ID that doesn't exist, you will see the following error codes:

MQTT: 401003 IotHubUnauthorized
AMQP: 404001 DeviceNotFound
HTTP: 404001 DeviceNotFound

Now if you have a registered a device but disabled it in IoT Hub , the errors are the same but you won't find the MQTT error in your trace. Instead client side you will receive a Server Unavailable error.

If you want, you can see these error codes for yourself by enabling tracing on the device connect/disconnect events .

So in closing: the behaviour of the IoT Hub is to not allow any devices to connect when unregistered.

In addition to Matthijs van der Veer answer, in the case of connection oriented direct protocol such as MQTT, when the registered device has been connected and the telemetry data is sent under the topic with unregistered device, for instance:

devices/UnregisteredDeviceId/messages/events/$.ct=application%2Fjson&$.ce=utf-8

then, the connected device is immediately disconnected from the IoT Hub.

I do recommend the following:

  • route your telemetry data messages to the blob storage
  • export ("excludeKeys":false) all device identities to the blob storage
  • find some messages which are not in the IoT hub identity registry entry
  • call the MS support and create the ticket for this issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM