Skip to content

IOT Hub requires TLS #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
geudrik opened this issue Jun 17, 2023 · 6 comments · Fixed by #63
Closed

IOT Hub requires TLS #60

geudrik opened this issue Jun 17, 2023 · 6 comments · Fixed by #63

Comments

@geudrik
Copy link

geudrik commented Jun 17, 2023

IOT Hub requires TLS for MQTT connections now. Changing the port to 443 and adding is_ssl=True on the MQTT client init in iot_mqtt.py doesn't work though. After that change, I get the following

498.412: INFO - Establishing a SECURE SSL connection to hubname.azure-devices.net:443
499.814: DEBUG - Sending CONNECT to broker...
499.816: DEBUG - Fixed Header: bytearray(b'\x10\xfe\x01\x00')
499.818: DEBUG - Variable Header: bytearray(b'\x04MQTT\x04\xc2\x00x')
499.826: DEBUG - Receiving CONNACK packet from broker
499.850: DEBUG - Got message type: 0x48
499.853: DEBUG - Got message type: 0x54
499.855: DEBUG - Got message type: 0x54
499.857: DEBUG - Got message type: 0x50
499.860: DEBUG - Got message type: 0x2f
499.863: INFO - MMQT error: Topic length 12576 in PUBLISH packet exceeds remaining length 46 - 2

I'm not familiar enough with MQTT to understand what this is actually telling me. But ultimately, this library doesn't currently work because of the TLS requirement and it's not supported (at all) without making code changes in the lib.

The code I'm using for testing is the default example code in this repo (example code), with the added addition of an adafruit_logger() instance to the IOTHubDevice init

@geudrik
Copy link
Author

geudrik commented Jun 21, 2023

Oh, and I was using a QtPy-S3 as my test device.

@benbarnett02
Copy link

@geudrik - Did you find an alternative?

@geudrik
Copy link
Author

geudrik commented Jul 17, 2023

I did not. I haven't had much time lately to keep messing around either :/

@migster
Copy link

migster commented Jul 21, 2023

Sharing this in case it's helpful. It seems related since IoT Central leverages IoT Hub. Last weekend I was trying to build an example that uses IoT Central and the device would not register. I was able to get the debug going and noticed it's not using SSL by default. I was able to get that turned up and get the device to register. I did it by changing the default in the adafruit_minimqtt. This thread has all of the details and debugs: https://forums.adafruit.com/viewtopic.php?p=980013#p980013

If can help get this fixed in anyway so the examples provided on the website work please or in testing fixes I'd be happy to do that. In the meantime I'll be tinkering with sensors and dashboards now that I have it reporting to up to Azure.

@benbarnett02
Copy link

I switched to micropython and used the Microsoft version, which unfortunately uses upip (deprecated and doesn’t work on new micropython releases) to download its dependencies. I swapped this to mip (new package manager) and it worked. (alternatively just manually install it’s dependencies or use a micropython version that supports upip).

Will post the code when I get home in a few days, but my Pico W has been reporting happily to azure for at least 24 hours!

@garretjacobson
Copy link

garretjacobson commented Aug 3, 2023

I too ran into issues with connectivity following the tutorials and the provided examples in the readme and simple test . Similar to the blog post shared above, ensuring is_ssl is true when interfacing with MQTT results in the device connecting.
Using Pico W with adafruit-circuitpython-raspberry_pi_pico_w-en_US-8.2.1 and adafruit-circuitpython-azureiot-py-2.5.15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants