eclipse / tahu

Eclipse Tahu addresses the existence of legacy SCADA/DCS/ICS protocols and infrastructures and provides a much-needed definition of how best to apply MQTT into these existing industrial operational environments.

Home Page:https://eclipse.org/tahu

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Python examples incorrectly set MQTT client ID to broker URL

tgrusendorf opened this issue · comments

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