Python examples incorrectly set MQTT client ID to broker URL
tgrusendorf opened this issue · comments
tgrusendorf commented
In the Python examples, the MQTT client ID is incorrectly set to the broker URL instead of letting it generate a random client ID. It looks like the parameters for the connect function were mistakenly copied to the constructor.
This prevents multiple Python clients from connecting to the same broker because they all use the same client ID.
client = mqtt.Client(serverUrl, 1883, 60)
client.on_connect = on_connect
client.on_message = on_message
client.username_pw_set(myUsername, myPassword)
deathByteArray = bytearray(deathPayload.SerializeToString())
client.will_set("spBv1.0/" + myGroupId + "/NDEATH/" + myNodeName, deathByteArray, 0, False)
client.connect(serverUrl, 1883, 60)
The first line should be changed to:
client = mqtt.Client()
Reference:
https://pypi.org/project/paho-mqtt/#client