Mosquitto sending messages to Azure IoTHub

Internet of Things IoT Frameworks 2 years ago

0 0 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating
_x000D_ _x000D_ Azure has implemented MQTT protocol in its IoTHub so I'm trying to use mosquitto to send messages from my pc. I'm creating azure devices using Device Explorer. In the beginning I generated SAS token from there, but it hasn't the "&skn=" part, so I tried to generate a new SAS using compatible event hub from visual studio. After that i tried to use mosquitto broker to send an MQTT message to my IoTHub using parameters in the CONNECT packet as explained here: https://azure.microsoft.com/en-us/documentation/articles/iot-hub-devguide/#endpoints However the connection doesn't work and i don't really know where I'm doing wrong. Using mosquitto_pub debugging I get this output: "Client Mosquitto sending CONNECT Error: The connection was lost" Can you please help me solve this issue? Thanks in advance. These are my mosquitto command, the first one is with SAS token generated using device explorer, the second using visual studio: mosquitto_pub -h {IotHub Hostname} -p 8883 -t devices/{deviceId}/messages/events -v -V mqttv311 -i {deviceId} -d -u {Hub Name}.azure-devices.net/{deviceId} -P "HostName={Hub name}.azure-devices.net;DeviceId={deviceId};SharedAccessSignature sr=https%3a%2f%2f{Event hub compatible name}.servicebus.windows.net%2fdevices&sig=k030AmvBkmlNwy%2fLd47N8jQuj808jJg9EXnAGmEUan4%3d&se=2913829726&skn=iothubowner" mosquitto_pub -h {IotHub Hostname} -p 8883 -t devices/{deviceId}/messages/events -v -V mqttv311 -i {deviceId} -d -u {Hub Name}.azure-devices.net/{deviceId} -P "HostName={Hub name}.azure-devices.net;DeviceId={deviceId};SharedAccessSignature=SharedAccessSignature sr={Hub name}.azure-devices.net%2fdevices%2f{deviceId}&sig=BYvo8GE%2fcOdnD8G3wsP7VElU4SwsVTSaACnif%2ffBj1k%3d&se=1456911258"

Posted on 16 Aug 2022, this text provides information on IoT Frameworks related to Internet of Things. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (0)

Post Answer

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.

Important Internet of Things Links