I'm trying to avoid the Azure SDK.
I am trying to connect to Azure IoT Hub with async-mqtt npm package.
I can successfully manually publish to default devices/${deviceId}/messages/events/
topic using just async-mqtt and I can easily read the published data with Azure Quickexample (https://github.com/Azure-Samples/azure-iot-samples-node/archive/master.zip).
When I try to read data just with async-mqtt I can't get any data (Following is the code I'm using).
await client.publish(`devices/${deviceId}/messages/events/`, "testing");
await client.subscribe(`devices/${deviceId}/messages/devicebound/`);
client.on('message', function (topic, message){
console.log("Received");
console.log(message.toString());
});
await client.end();
I can't get what I'm doing wrong.
Edit: This is the client configuration
var client = MQTT.connect(`mqtts://${iotHubName}.azure-devices.net:8883`, {
keepalive: 10,
clientId: MyNodeDevice,
protocolId: 'MQTT',
clean: true,
protocolVersion: 4,
reconnectPeriod: 1000,
connectTimeout: 30 * 1000,
username: userName,
password:"SAS TOKEN",
rejectUnauthorized: false,
});