azure - 如何捕获 Azure 设备 SDK 中引发的错误?

标签 azure azure-iot-hub

我正在使用Azure Device SDK .NET Core,以便将我的设备连接到 Azure IoT 中心。服务器有时会拒绝来自设备的一些消息(例如孪生更新或遥测消息)并以状态代码 400 进行响应。因此,客户端会抛出异常,但由于其异步性质,它们会被吞没在 Azure 内部的某个位置SDK,并且从未向我的代码抛出过问题。

我如何才能真正收到有关这些错误的通知,以便我可以处理和显示它们?

我还可以从 Azure Device SDK 代码中看到它使用某种日志记录 (EventSource),但这在代码中从未启用:

From Logging.Common.cs:
Log.IsEnabled() // always returns false

您能否指出一些方法,让我能够 1) 在 Azure 设备 SDK 中实际启用日志记录并 2) 查找实际记录的内容?

更新:有关在某处被吞没的异常的详细信息

// Fired here after I send twin reported properties to server:
AmqpTransportHandler.VerifyResponseMessage:
if (status >= 400)
{
    throw new InvalidOperationException("Service rejected the message with status: " + status);
}

// Then becomes caught and re-fired here:                   
AmqpTransportHandler.SendTwinPatchAsync:                    
       throw AmqpClientHelper.ToIotHubClientContract(exception);

// Then it disappears somewhere in the "dance" of the async tasks

最佳答案

关于azure - 如何捕获 Azure 设备 SDK 中引发的错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53301710/

相关文章:

azure - 如何备份可承受 Azure 服务器删除的 Azure SQL

azure - 在 Windows Azure 上交换插槽但不复制 AppSettings

git - RPC 失败 : curl 56 failure when receiving data from the peer

如果生存时间超过 1 天,Azure 通知中心注册到期日期不会更新

python - 如何在Python中获取从IoT Hub发送到设备的消息的(反馈)确认?

azure - 当我在 Azure 中发布天气预报 API 时出现 500 错误,如何调试?

c# - Azure 从连接的设备/DPS 服务获取 IoTHub 连接字符串

Azure Functions - 如何为我的 IoTHub 消息设置 IoTHubTrigger?

Azure 数据资源管理器和 IoT 中心表映射配置

azure - 设备每 65 分钟重新连接到 Azure IoT 中心