Token connect not possible 1.4
with python 3.7 and client 1.6 not possible connect to server using Token (examples) . TBDeviceMqttClient init does not have this option, require PORT and username + password if you want connect with TOKEN connection string client = TBDeviceMqttClient("xxx.xxx.xxx.xxx",1883,None, "TOKEN")
I had i simular issue This example in documentation no longer works with: paho-mqtt==1.6.1 tb-mqtt-client==1.4.1
client = TBDeviceMqttClient("127.0.0.1", "A1_TEST_TOKEN")
# Connect to ThingsBoard
client.connect()
I found a solution using named parameters
client = TBDeviceMqttClient("127.0.0.1", username="A1_TEST_TOKEN")
If you look at the code for TBDeviceMqttClient you will see port is the second argument. Don't know how this was before.
class TBDeviceMqttClient:
def __init__(self, host, port=1883, username=None, password=None, quality_of_service=None, client_id="",
chunk_size=0):
Anyway, use named arguments to avoid such problems in the future.
Cannot connect even with named arguments. Always getting "RuntimeError: Message publish failed: The client is not currently connected.".
Managed to get it work by downgrading to version 1.1 python -m pip install tb-mqtt-client==1.1
A big red flag...