【问题标题】:MessagingEntityNotFoundException: The messaging entity 'ihsuprodsgres029dednamespace:eventhub:' could not be foundMessagingEntityNotFoundException:找不到消息传递实体“ihsuprodsgres029dednamespace:eventhub:”
【发布时间】:2017-11-27 06:06:00
【问题描述】:

我只是尝试使用 Azure IOT Hub 将我的设备连接到云。但我收到如下错误。

MessagingEntityNotFoundException:找不到消息传递实体“ihsuprodsgres029dednamespace:eventhub:iothub-ehub-”。 TrackingId:4772b610-8ff3-4709-8ea9-ffcd5784fe1c_B4,SystemTracker:ihsuprodsgres029dednamespace:eventhub:iothub-ehub-sibeeshiot-176205-a588b66686〜16383 | team01,时间戳:2017年6月23日下午3时07分54秒TrackingId:41110b704d814af497fd9924da6714d8_G4,SystemTracker :gateway2,时间戳:2017 年 6 月 23 日下午 3:07:55,参考 ID:41110b704d814af497fd9924da6714d8_G4

如果您遇到过同样的问题,请您帮我解决一下。下面是我正在尝试的代码。

static void Main(string[] args) {
    Console.WriteLine("Receive messages. Ctrl-C to exit.\n");
    eventHubClient = EventHubClient.CreateFromConnectionString(connectionString, iotHubD2cEndpoint);

    var d2cPartitions = eventHubClient.GetRuntimeInformation().PartitionIds;

    CancellationTokenSource cts = new CancellationTokenSource();

    System.Console.CancelKeyPress += (s, e) = >{
        e.Cancel = true;
        cts.Cancel();
        Console.WriteLine("Exiting...");
    };

    var tasks = new List < Task > ();
    foreach(string partition in d2cPartitions) {
        tasks.Add(ReceiveMessagesFromDeviceAsync(partition, cts.Token));
    }
    Task.WaitAll(tasks.ToArray());
}
private static async Task ReceiveMessagesFromDeviceAsync(string partition, CancellationToken ct) {
    var eventHubReceiver = eventHubClient.GetConsumerGroup("Team01").CreateReceiver(partition, DateTime.UtcNow);
    while (true) {
        if (ct.IsCancellationRequested) break;
        EventData eventData = await eventHubReceiver.ReceiveAsync();
        if (eventData == null) continue;

        string data = Encoding.UTF8.GetString(eventData.GetBytes());
        Console.WriteLine("Message received. Partition: {0} Data: '{1}'", partition, data);
    }
}

【问题讨论】:

    标签: c# azure azure-web-app-service azure-iot-hub azure-iot-sdk


    【解决方案1】:

    您的 iotHubD2cEndpoint 值似乎不正确,与事件中心兼容的名称(可能您正在使用 messages/events,例如 Azure IoT 中心端点)。

    以下屏幕 sn-p 显示事件的事件中心兼容端点:

    • 另一种选择是使用 Azure IoT 中心连接字符串和端点事件,请参见以下示例:

      iotHubD2cEndpoint = "消息/事件" connectionString = "HostName=*****.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=******"

    【讨论】:

    • 这个屏幕在哪里?有关如何查找此信息的任何建议?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多