Mosquitto 1.0 python changes

Looks like there have been some changes to the Mosquitto v1.0.1 python libraries. So far only hit the one but it was quite a major one. The connect method has been changed. If you try and run your code you will get

Traceback (most recent call last):
File "test.py", line 13, in <module>
mqttc.connect(broker, port, 60, True)
TypeError: connect() takes at most 4 arguments (5 given)

In 1.0 the connect function changed from:
def connect(self, hostname="localhost", port=1883, keepalive=60, clean_session=True):
to:
def connect(self, host, port=1883, keepalive=60):

So all it needed was to remove the true flag from the connect statement and then the script worked.

Leave a comment

Your email address will not be published. Required fields are marked *