Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token connect not possible 1.4 #30

Open
dim123dim123 opened this issue Sep 19, 2022 · 2 comments
Open

Token connect not possible 1.4 #30

dim123dim123 opened this issue Sep 19, 2022 · 2 comments

Comments

@dim123dim123
Copy link

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 dim123dim123 changed the title Token connect not possible 1.6 Token connect not possible 1.4 Sep 19, 2022
@tbousiou
Copy link

tbousiou commented Nov 7, 2022

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.

@ManuelAlvesDtx
Copy link

ManuelAlvesDtx commented May 30, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants