I don't know what's wrong with this node.js code. I don't get any error messages, but I can't see the messages in Event Hub. I'm able to send the same payload / keys from Python to the same EventHub without issue. Any suggestions?
const { EventHubClient } = require("@azure/event-hubs");
// Connection string - primary key of the Event Hubs namespace.
const connectionString = "Endpoint=sb://sensor-partner-eh-namespace-cfrlr.servicebus.windows.net/;SharedAccessKeyName=XXX;SharedAccessKey=XXX;";
// Name of the event hub. For example: myeventhub
const eventHubsName = "sensor-partner-eh-03";
const connectionString = "Endpoint=sb://sensor-partner-eh-namespace-cfrlr.servicebus.windows.net/;SharedAccessKeyName=XXX;SharedAccessKey=XXX;";
// Name of the event hub. For example: myeventhub
const eventHubsName = "sensor-partner-eh-03";
// Open Payload File
const payload = require("./payload.json");
const payload = require("./payload.json");
async function main() {
const writeclient = EventHubClient.createFromConnectionString(connectionString, eventHubsName);
const writeclient = EventHubClient.createFromConnectionString(connectionString, eventHubsName);
for (let i = 0; i < 100; i++) {
var eventData = payload;
console.log(JSON.stringify(eventData,null,4));
console.log(JSON.stringify(eventData,null,4));
await writeclient.send(eventData,0);
}
await writeclient.close();
}
}
main().catch(err => {
console.log("Error occurred: ", err);
});
console.log("Error occurred: ", err);
});