Pico W: Issues with ussl / usocket with encrypted MQTT #9259
-
Hi - I am seeing error "MQTTException: 5" when trying to connect to an authenticated HiveMQ MQTT broker when connecting via TLS. To try and narrow down the issue I have tested just sending the same raw data for a MQTT CONNECT message from both MicroPython and Python. Server Response:- MicroPython: \x20\x00\x05 e.g. "MQTTException: 5" As we are sending the same data to the server then it would seem like an issue with the ussl / usocket module ??? The rawdata test code is shown below (Note: the server and msg have been truncated as it has password information) ` server = '206..............5571eac9.s1.eu.hivemq.cloud' msg = b'\x10\x2a\x00\x04\x4d\x51.......................\x6d\x73\x59\x78' sock = socket.socket() sock.write(msg) resp = sock.read(4) print('Response: ',resp) ` Any thoughts ??? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
@IanW6374 could you add this to verify that
From MicroPython docs about
So both values should be the same, if not then there is the problem. |
Beta Was this translation helpful? Give feedback.
-
Hi, I have a very noob question hope you guys don't laugh about. Where do you guys get the certificate files from? I'm doing the exactly same thing and got stuck at this ssl thing. When I'm using an iOS app to send and receive MQTT, I only need to "kick in box" as an option labeled "SSL", and everything worked fine. In this case why do I need a seperate file? Many thanks. |
Beta Was this translation helpful? Give feedback.
@IanW6374 could you add this to verify that
sock.write(msg)
is sending the whole message?From MicroPython docs about
socket.write
So both values should be the same, if not then there is the problem.
In case they are the same, I would try to use Wireshark and see if I can spot any differences between Python and MicroPython. 🤔