Azure / azure-event-hubs-node

Node client library for Azure Event Hubs https://azure.microsoft.com/services/event-hubs
MIT License
50 stars 46 forks source link

Read Azure IoT Hub messages from custom endpoints #168

Closed formulahendry closed 5 years ago

formulahendry commented 5 years ago

By following the instruction with below code:

const { EventHubClient } = require('@azure/event-hubs');

async function main() {
  const client = await EventHubClient.createFromIotHubConnectionString(process.env["IOTHUB_CONNECTION_STRING"]);
  const hubInfo = await client.getHubRuntimeInformation();
  console.log(hubInfo);
  await client.close();
}

main().catch((err) => {
  console.log(err);
});

I could read Azure IoT Hub messages from built-in endpoints. However, when I route message to a custom endpoint (e.g. Azure Storage containers, Event Hubs), I could no longer read the message.

Could I read all messages arrived in IoT Hub no matter where the message will be routed?

Related to https://github.com/Microsoft/vscode-azure-iot-toolkit/issues/180

amarzavery commented 5 years ago

I don't think that is supported. When you provide the iothub connectionstring, we try to connect to the iothub service and they send a redirect error which contains information about the corresponding EventHub endpoint. This is used to then receive messages from the Event Hub.

Reading messages from the Azure Storage container would happen over HTTP protocol. You would be better off using the package from this repo.

If you are redirecting the messages to an EventHub and if you have the connection string of that EventHub, then you can use the EventHub client to establish a connection to that EventHub and receive messages from it.

@pierreca from IotHubs and @sjkwak from EventHubs can provide more information on this.

AlexGhiondea commented 5 years ago

It looks like there isn't anything we can do here - please feel free to reactivate the issue if that is not the case.