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
tsjoiner
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 = f.read()
print("Got Key")

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

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

client.set_callback(sub_cb) 
client.connect()
client.subscribe(topic="e1474d/temp/sub") 


while True:     
    print("Sending ON") 
    client.publish(topic="e1474d/temp", msg="high")
    time.sleep(1) 
    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")
        time.sleep(1)
Message:

Code: Select all

Traceback (most recent call last):
  File "main.py", line 80, in <module>
  File "umqtt/simple.py", line 203, in check_msg
NotImplementedError: 
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?

securigy
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