Hello Allesanddro,
Thanks for taking the time to not only comment but to try this code snippet.
Looking through the error you are getting, the issue is you are trying to connect to Azure IOT Hub, which is not fully MQTT compliant today. My code is connecting to my local MQTT broker (Eclipses Mosquito) which is then via the Azure IOT Python SDK making a call back to your Azure IOT Hub.
Mosquitto does not require (by default) TLS, Authentication or a specific topic structure.
Can you explain what you are trying to achieve and I will be more than happy to see if I can help you find a solution.
My code's flow looks something like
- Never ending Python loop
- Reading from Local MQTT broker (you cannot use Azure as yet)
- For each message, convert MQTT message into Azure IOT SDK call and publish back to Azure IOT-Hub.
Happy to help in any way I can.