MessagingEntityNotFoundException: The messaging entity 'ihsuprodsgres029dednamespace:eventhub:' could not be found
Asked Answered
W

2

6

I am just trying to connect my device to cloud using Azure IOT Hub. But I am getting an error as below.

MessagingEntityNotFoundException: The messaging entity 'ihsuprodsgres029dednamespace:eventhub:iothub-ehub-' could not be found. TrackingId:4772b610-8ff3-4709-8ea9-ffcd5784fe1c_B4, SystemTracker:ihsuprodsgres029dednamespace:eventhub:iothub-ehub-sibeeshiot-176205-a588b66686~16383|team01, Timestamp:6/23/2017 3:07:54 PM TrackingId:41110b704d814af497fd9924da6714d8_G4, SystemTracker:gateway2, Timestamp:6/23/2017 3:07:55 PM, referenceId: 41110b704d814af497fd9924da6714d8_G4

Can you please help me with it, if you have ever faced the same issue. Below is the code I am trying.

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);
    }
}
Wickham answered 23/6, 2017 at 15:32 Comment(0)
A
4

It looks like your iotHubD2cEndpoint value is not correct Event Hub-compatible name (probably you are using the messages/events such as an Azure IoT Hub Endpoint).

The following screen snippet shows the Event Hub compatible endpoint for Events:

EventHubEndpoint

  • The other option is to use an Azure IoT Hub Connection string and Endpoint Events, see the following example:

    iotHubD2cEndpoint = "messages/events" connectionString = "HostName=*****.azure-devices.net;SharedAccessKeyName=iothubowner;SharedAccessKey=******"

Accompanist answered 23/6, 2017 at 18:32 Comment(1)
Where is this screen? Any suggestions on how to find this information?Dogtooth
I
0

For others getting here... I found the Event Hub compatible endpoint via:

  • Azure portal (https://portal.azure.com)
  • Open your IotHub configuration
  • On left hand menu...
  • Hub settings, Built-in endpoints
  • Below Event Hub compatible endpoint...
  • Event Hub compatible endpoint.
Inconsequential answered 21/12, 2023 at 16:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.