umqtt simple problem.

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
Thalass
Posts: 2
Joined: Sat Oct 23, 2021 12:33 am

umqtt simple problem.

Post by Thalass » Sat Oct 23, 2021 12:51 am

Hey guys. I just flashed my ESP8266 with micropython last week and it's been pretty great so far.

Similar to this thread I started mucking about with umqtt.simple with my broker allowing anonymous clients, but decided to slightly increase the security by requiring usernames. This is fine on a python script I have on my computer that is subscribed to the broker, but on my ESP it will not play nice.

Obviously if I don't include the user paramter in the MQTTClient thing, it fails to connect with an "MQTTException 5" which I believe is the broker denying access, which is fine. If I include the user I always get

Code: Select all

Traceback (most recent call last):
  File "<stdin>", line 32, in <module>
  File "simple.py", line 79, in connect
TypeError: object of type 'NoneType' has no len()
(line 32 being where c.connect() is in my script)
I've tried sending it as a byte ( b"namehere", also bytes("namehere", 2, "big"), and a few other bad attempts, but other than an integer they all return the same error. I even checked by having print(len(user)) right below the user="username" entry, but despite the script printing lengths, simple.py always seems to interpret the data as "NoneType".

I'm still pretty new at coding in general, I've only ever dabbled. So it's got me beat.

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: umqtt simple problem.

Post by pythoncoder » Mon Oct 25, 2021 7:09 am

If you have a username you must also have a password. The correct format for both is b"text".
Peter Hinch
Index to my micropython libraries.

Thalass
Posts: 2
Joined: Sat Oct 23, 2021 12:33 am

Re: umqtt simple problem.

Post by Thalass » Tue Nov 02, 2021 12:07 am

Ah that was it :lol:
Thanks!

Post Reply