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

MQTT client initialization failed #2707

Open
blackstardlb opened this issue Mar 26, 2024 · 3 comments
Open

MQTT client initialization failed #2707

blackstardlb opened this issue Mar 26, 2024 · 3 comments

Comments

@blackstardlb
Copy link

blackstardlb commented Mar 26, 2024

Describe the bug
MQTT client initialization failed. Was working until latest update.

To Reproduce
Steps to reproduce the behavior:

  1. Start Glances with the following options:
  image: nicolargo/glances:latest-full
  container_name: glances_mqtt
  restart: always
  pid: host
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - **/glances/data/glances.conf:/glances/conf/glances.conf
  environment:
    - "GLANCES_OPT= -C /glances/conf/glances.conf --disable-plugin all --enable-plugin cpu,mem,containers,system,fs,uptime --quiet --export mqtt"
  networks:
    - proxy
  1. See error

glances_mqtt | MQTT client initialization failed
glances_mqtt | Exception ignored in: <function Client.del at 0x7fea5f6316c0>
glances_mqtt | Traceback (most recent call last):
glances_mqtt | File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 874, in del
glances_mqtt | self._reset_sockets()
glances_mqtt | File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
glances_mqtt | self._sock_close()
glances_mqtt | File "/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
glances_mqtt | if not self._sock:
glances_mqtt | ^^^^^^^^^^
glances_mqtt | AttributeError: 'Client' object has no attribute '_sock'
glances_mqtt | Connection to MQTT server mosquitto:1883 failed with error: Client.init() missing 1 required positional argument: 'callback_api_version'

Expected behavior
no error.

Environement (please complete the following information)

  • Glances & psutil versions: To be completed with result of: glances -V
    Glances v3.4.0.5 with PsUtil v5.9.8

You can also pastebin:

@mlares85
Copy link

This is due to paho mqtt changing things for their 2.0.0 release. It has broken all MQTT code that used version 1.x

Relevant github discussion:
eclipse/paho.mqtt.python#814

Their reference for migration to the new 2.0.0 API usage:
https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html

The alternative is to rebuild the docker container and in the optional requirements file specify the specific version of paho-mqtt-1.6.1

@blackstardlb
Copy link
Author

blackstardlb commented Mar 27, 2024

I downgraded to 3.4.0.3-full for now

@nicolargo
Copy link
Owner

Related to #2700

Dev branch should be ok and manage correctly both MQTT API version 1 and version 2.

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

No branches or pull requests

3 participants