[英]How to get "Total number of messages on the IoT Hub exceeded the allocated quota" message from Azure iot sdk c
[英]Is IoT hub message feedback absolute confirmation?
我正在工作 Azure Function 通過 IoT 中心將數據發送到少數設備。 我正在嘗試記錄整個過程,但不確定我當前的解決方案是否足夠。
到目前為止,我正在使用消息反饋(如文檔中所述)來記錄設備是否收到發送消息。
“IoT 中心不生成反饋消息。如果雲到設備消息到達已完成 state,IoT 中心將生成反饋消息。” 據我了解,如果我收到上述反饋,則確認設備已成功/未成功接收消息。
我的理解是,這是設備正確接收或未接收消息的絕對確認嗎? 或者還有另一種選擇是確認嗎?
我建議閱讀接收雲到設備交付反饋部分,以便更好地理解這一點。 本節介紹如何設置確認反饋選項。 Azure 物聯網中心在正面和負面場景中提供反饋。
如果您使用以下代碼commandMessage.Ack = DeliveryAcknowledgement.Full;
如文章中所述將消息Ack設置為完整; ,您將在已完成和死信場景(正面和負面結果)中收到一條消息。
如果您專門針對成功消息,則需要將確認設置為Positive 。 然后您收到的反饋是確認消息已被設備成功接收。
希望這可以幫助!
我按照以下步驟使用 azure function 向物聯網設備發送消息。
@LeelaRajesh_Sayana 的附加答案。
創建了 IoT 中心並添加了設備
添加設備名稱並點擊保存
try
{
log.Loginformation($"Message sent : {message}");
}
catch (Exception ex)
{
log.LogError($"Error sending message :{ex.Message});
}
using System;
using Microsoft.Azure.Devices;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
namespace AzureFunctionIoT
{
public static class SendMessageToIoTDevices
{
[FunctionName("SendMessageToIoTDevices")]
public static void Run([TimerTrigger("0 0 0 * * *")]TimerInfo myTimer, ILogger log)
{
string connectionString = Environment.GetEnvironmentVariable("IoTHubConnectionString");
ServiceClient serviceClient = ServiceClient.CreateFromConnectionString(connectionString);
var message = new Microsoft.Azure.Devices.Message(System.Text.Encoding.ASCII.GetBytes("Hello IoT Devices"));
serviceClient.SendAsync("<DeviceId>", message).GetAwaiter().GetResult();
log.LogInformation("Message sent successfully");
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.