Azure IotHub doesn't receiving any messages - azure-iot-hub

I'm just set up my iot hub that should receiving messages from my test device. It work's perfect about one day. On second day when I send messages to this azure service I don't getting any exception but my iot hub doesn't receving any messages. I don't know what is the main problem of that ? Additionaly I have one worker role that handle all messages on event hub processor from this iot hub. Maybe is there any extra settings that stops my iot hub or something more ? I can't find any information on other sites maybe someone have similiar problem ?

As per my understanding,
Your device sends message to IOT Hub
Your worker role reads message from this IOT hub using EHP
If this is the case and you are not receiving messages at EHP than CONSUMER GROUP could be the issue. Basically, IOT hub serves messages per consumer group. By default each IOT Hub has $Default group. If some other service is already reading message from this consumer group than you won't be able to get message.
You can create another consumer group for your worker role. IOT Hub serves same message to each consumer group.

Related

Azure IoT on Edge - IoTSDK - Read batch of messages from ModuleClient

I'm tryng to develop an high-frequency message dispatching application and i'm observing for the behavior of the SDK about message reading from the ModuleClient connected to the edgeHub by using "MQTT on TCP Only" transport settings.
Seems that there is no way to read multiple messages at time (batch) from the edgeHub (I think is something related to the underlying protocol).
So the result is that one must sequentially read a message, process it and give the ack to the hub.
Does exist a way to process multiple message at time without waiting for the processing of the previous?
Is this "limitation" tied to the underlyng protocol?
I'm using Microsoft.Azure.Devices.Client 1.37.2 on a .NET Core 3.1 application deployed on Azure Kubernetes (AKS) by using Azure IoT Edge on Kubernetes workload.
You are correct, you cannot use batch in MQTT protocol. This is a limitation tied to IoTHub when using MQTT Protocol.
IoT Hub only supports batch send over AMQP and HTTPS at the moment.
The MQTT implementation loops over the batch and sends each message
individually.
Ref: https://github.com/Azure/azure-iot-sdk-csharp
Suggest that you add a new feature request, if need IoTHub to support batch when connecting using MQTT: https://feedback.azure.com/forums/321918-azure-iot-hub-dps-sdks

Where can I find azure IoT device messages?

I have sent messages to Azure IoT Hub device called dev1, I could not see the messages in IoT Hub but, I can read the messages only when the client application is online when the sender is sending messages. Azure IoT Hub supports only online messaging and no offline messaging? If offline message support is there, where are these messages are stored, I couldn't see the messages in IoT Hub.
When I configure the custom endpoint as Blob storage, I can see messages are stored in blobs.
Please help me on this.
Thanks in advance
If I understand correctly you are looking for reading the messages directly on IoT Hub portal UI. If that is the case, then one of the things which you can make sure about D2C Messages in IoT Hub portal (UI perspective) is looking at the Metrics chart (See below Images). For reading the actual payload you have to make use of in-built Event Hub endpoint or routing to other supported endpoints.(You have already mentioned in your scenario-Client/Sender applications, So I think you have already known this method of reading messages)
The Metrics chart atleast tells you that the messages are received in IoT Hub (UI), you can't read them on the Portal(UI).
IoT Hub is built on top of Event Hubs, and that's where your messages will be until you start reading them. They will be stored there for 1 day by default, although you can change that up to 7 days. For more information on retention, please read this page.

RabbitMQ and IoT device: keep queue open?

We're using RabbitMQ in a new project. We'll have IoT devices communicating with queues.
For the devices to send info to the cloud we don't see any issues, however sometimes we need to deliver messages from our backend to the IoT devices. For this we let the devices open an exclusive queue. This works perfectly, as long as the devices are online. When they aren't, the queue is closed and no messages can be send to it anymore.
Is there a way to keep the queue open, so messages are kept until the IoT device comes back online?
Vice-versa: Is there some way to have guaranteed delivery starting at the IoT device. For example: energy measurements every 15 minutes. If the connection drops, messages should be stored on disk (to prevent message loss in case of power cut). They are sent later on when the connection comes back online. Does a service or client library exist that implements this or do we need to develop this ourselves?
Is there a way to keep the queue open, so messages are kept until the
IoT device comes back online?
Use a regular queue, and make sure it's durable if you'd like it to survive RabbitMQ restarts.
Is there some way to have guaranteed delivery starting at the IoT
device.
That depends on the library you are using, but you don't tell us what library nor what protocol you're using (AMQP vs MQTT, for instance).
Some libraries offer automatic reconnect and re-creation of topology (queues, exchanges, etc) but I'm not aware of any that offer local storage of messages until the broker is available again. You'll have to code that yourself.
Please carefully read the documentation with regard to publisher confirmations and consumer acknowledgements, as those are both necessary for reliable messaging link.
NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.
Our Cloud has several exchanges and credentials called CredentialsBucket assigned to a set of IoT devices. When an IoT device register, we provide them this credentials that includes a durable queue and exchange. When the IoT device push messages, it goes to Cloud through the exchange where we do additional security check using HMAC.
When Cloud send a message, it send it directly to his queue (no persistent messages in our case) and the IoT device do the same kind of security check.

How can I define a consumer group into Azure IoT Hub?

In order to consume data on Azure IoT Hub into Microsoft Power Bi I have created a Stream Analytics job. From the documentation, i found out that "Each stream Analytics Job input should be configured to have its own consumer group". So i have to create into my Azure IoT Hub a consumer group. How can I define a consumer group into Azure IoT Hub?
In order to create a new consumer group go to your Iot Hub instance in Azure.
Go to Endpoints tab, choose the correct Built-in endpoints, in case it's device to cloud messages it should be Events (message/Events).
There you can add a consumer group.

How to receive device connection events from Azure IoT Hub?

Is it possible to get notified that a device has connected to IoT hub without polling?
The only option I've found is to poll RegisteryManager.GetDevicesAsync() and loop through the registered devices to see if they are connected or not. I could poll, however I have no idea what sort of throttling limits exist.
That code looks like:
var devices = await registryManager.GetDevicesAsync(maxCountOfDevices);
if (devices != null)
{
foreach (var device in devices)
{
// do something with the connection state like
// notify services
device.ConnectionState
}
}
What I'd like is to be able to get all registered devices, keep them in memory, and just listen for connection events.
Microsoft Azure IoT team suggests implementing the heartbeat pattern because connectionState is not accurate:
https://learn.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-identity-registry#device-heartbeat
I Tried it with operation monitoring in Azure IOT Hub. It provide an event hub endpoint to read the verbose operation. So here i find the event of connection and disconnection of IOT device to IOT hub. But now the issue is device messages and connection/disconnection events are async.