thingsboard-python-client-sdk icon indicating copy to clipboard operation
thingsboard-python-client-sdk copied to clipboard

Token connect not possible 1.4

Open dim123dim123 opened this issue 3 years ago • 2 comments

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")

dim123dim123 avatar Sep 19 '22 13:09 dim123dim123

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.

tbousiou avatar Nov 07 '22 11:11 tbousiou

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...

ManuelAlvesDtx avatar May 30 '23 08:05 ManuelAlvesDtx