Code Monkey home page Code Monkey logo

Comments (9)

runningman84 avatar runningman84 commented on June 12, 2024 1

looks good

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

Sure, I'll have a look

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

It seems by default there is no client_id generated. See here

        if client_id == "" or client_id is None:
            if protocol == MQTTv31:
                self._client_id = base62(uuid.uuid4().int, padding=22)
            else:
                self._client_id = b""

Also, I did not find a clean way to get the client id, as it is a private attribute of client object.

Do you need to have the client id auto generated, or do you want to specify it manually?

from mqtt-exporter.

runningman84 avatar runningman84 commented on June 12, 2024

I would specify it manually using an ENV variable... if the variable is not present the client_id can be auto generated

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

ok, I'll add the possibility to specify the client id, and I'll expose it in the metrics if existing.

If the variable is not present the client_id can be auto generated

According the documentation, when client-id is empty, this is up to the MQTT broker to generate it. But the broker does not seem to send back the client-id to the client. In debug mode, client._client_id remains empty even during message processing.

If I force the client-id auto generation on client side, I would have to handle all possible issues such as client id already used.

from mqtt-exporter.

runningman84 avatar runningman84 commented on June 12, 2024

Yes just leave the id empty and let the server auto generate something...

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

But the broker does not seem to send back the client-id to the client.

Confirmed here: eclipse/paho.mqtt.python#237 (comment) :

No, if the server generate the clientid then it is not send to client.`

It looks like the behavior is fixed in MQTT v5: eclipse/paho.mqtt.python#237 (comment)
But default protocol in python MQTT client library is MQTT3.1.1.

I'll try with an option to choose the MQTT 5 version. If it is working, we will be able to get back the id generated by the broker and to expose it in Prometheus.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

would it work for you? #26.
Feel free to test.

I still need to add some functional tests before merging it.

from mqtt-exporter.

kpetremann avatar kpetremann commented on June 12, 2024

Code merged

from mqtt-exporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.