mqtt with tls - problem subscribing

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
Posts: 22
Joined: Tue Sep 05, 2017 3:09 pm
Location: Alberta Beach, Alberta, Canada

mqtt with tls - problem subscribing

Post by tsjoiner » Sat Mar 02, 2019 12:46 am

Trying to track down some weirdness implementing umqtt with ssl enabled. I have a simple program to test umqtt and with basic user:password compared to user:password with ssl=True. Without ssl I can publish and subscribe no problem. However, when ssl is enabled, publish works fine but subscribe only work with client.wait_msg() and exits when I use client.check_msg().

My code minus networking stuff:

Code: Select all

with open("key", "r") as f: 
    key =
print("Got Key")

with open("cert", "r") as f: 
    cert =
print("Got Cert")	

client = MQTTClient(client_id="e1474d", server="", port=8883,
                    user="MyTCPusername", password="MyTCPpassword",
                    keepalive=5000, ssl=True,
                    ssl_params={"cert":cert, "key":key, "server_side":False})


while True:     
    print("Sending ON") 
    client.publish(topic="e1474d/temp", msg="high")
    print("Sending OFF") 
    client.publish(topic="e1474d/temp", msg="low")
    for i in range(14):
        print("waiting for new message")
        #only client.wait_msg works with full tls - some problem at line 203 of umqtt library
        client.check_msg() # two functions exist: client.wait_msg() or client.check_msg()
        print("received new message")

Code: Select all

Traceback (most recent call last):
  File "", line 80, in <module>
  File "umqtt/", line 203, in check_msg
MicroPython v1.10-8-g8b7039d7d on 2019-01-26; ESP module with ESP8266
Type "help()" for more information.
I see something is not implemented here but why no problem when ssl=False?

Posts: 7
Joined: Wed Aug 21, 2019 12:37 am

Re: mqtt with tls - problem subscribing

Post by securigy » Wed Aug 21, 2019 12:39 am

Did you resolve your problem and if yes, how?

Post Reply