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

Fix: mqtt_client.Client() missing 1 required positional argument callback_api_version #52

Open
wants to merge 1 commit into
base: humble-devel
Choose a base branch
from

Conversation

thkfighter
Copy link

@thkfighter thkfighter commented Feb 18, 2024

Before fix,

$ ros2 launch vda5050_connector mqtt_bridge.launch.py 
[INFO] [launch]: All log files can be found below /home/damon/.ros/log/2024-02-17-22-52-36-339557-damon-lenovo-46076
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mqtt_bridge.py-1]: process started with pid [46088]
[mqtt_bridge.py-1] Exception ignored in: <function Client.__del__ at 0x7f14f25f1c60>
[mqtt_bridge.py-1] Traceback (most recent call last):
[mqtt_bridge.py-1]   File "/home/damon/.local/lib/python3.10/site-packages/paho/mqtt/client.py", line 874, in __del__
[mqtt_bridge.py-1]     self._reset_sockets()
[mqtt_bridge.py-1]   File "/home/damon/.local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
[mqtt_bridge.py-1]     self._sock_close()
[mqtt_bridge.py-1]   File "/home/damon/.local/lib/python3.10/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
[mqtt_bridge.py-1]     if not self._sock:
[mqtt_bridge.py-1] AttributeError: 'Client' object has no attribute '_sock'
[mqtt_bridge.py-1] Traceback (most recent call last):
[mqtt_bridge.py-1]   File "/home/damon/colcon_ws/install/vda5050_connector/lib/vda5050_connector/mqtt_bridge.py", line 58, in <module>
[mqtt_bridge.py-1]     main()
[mqtt_bridge.py-1]   File "/home/damon/colcon_ws/install/vda5050_connector/lib/vda5050_connector/mqtt_bridge.py", line 41, in main
[mqtt_bridge.py-1]     mqtt_bridge = MQTTBridge()
[mqtt_bridge.py-1]   File "/home/damon/colcon_ws/install/vda5050_connector/local/lib/python3.10/dist-packages/vda5050_connector_py/mqtt_bridge.py", line 220, in __init__
[mqtt_bridge.py-1]     self.mqtt_client = mqtt_client.Client()
[mqtt_bridge.py-1] TypeError: Client.__init__() missing 1 required positional argument: 'callback_api_version'
[ERROR] [mqtt_bridge.py-1]: process has died [pid 46088, exit code 1, cmd '/home/damon/colcon_ws/install/vda5050_connector/lib/vda5050_connector/mqtt_bridge.py --ros-args -r __node:=mqtt_bridge -r __ns:=/vda5050 --params-file /tmp/tmpdpdr7fj5'].

After fix,

$ ros2 launch vda5050_connector mqtt_bridge.launch.py 
[INFO] [launch]: All log files can be found below /home/damon/.ros/log/2024-02-17-23-19-26-460626-damon-lenovo-83003
[INFO] [launch]: Default logging verbosity is set to INFO
[INFO] [mqtt_bridge.py-1]: process started with pid [83005]
[mqtt_bridge.py-1] [INFO] [1708183166.755924519] [vda5050.mqtt_bridge]: Configuring ROS topics
[mqtt_bridge.py-1] [INFO] [1708183166.763722569] [vda5050.mqtt_bridge]: Connected to MQTT Broker!
[mqtt_bridge.py-1] [INFO] [1708183166.763942836] [vda5050.mqtt_bridge]: Finished configuring ROS topics
[mqtt_bridge.py-1] [INFO] [1708183166.764657397] [vda5050.mqtt_bridge]: Node mqtt_bridge has started successfully.

@leandropineda
Copy link
Member

Hey @thkfighter ,

I was able to reproduce the issue, thanks for creating a PR for it.

I'm assuming you are using the docker container on the vda5050_adapter_examples repository. If so, I'd fix this by pinning paho-mqtt version to 1.6.1 i.e.

diff --git a/docker/build/development.Dockerfile b/docker/build/development.Dockerfile
index 46c9dcf..df65fb4 100644
--- a/docker/build/development.Dockerfile
+++ b/docker/build/development.Dockerfile
@@ -55,7 +55,7 @@ RUN apt-get update \
 # Install pip dependencies
 RUN pip3 install --no-cache \
    transforms3d \
-   paho-mqtt
+   paho-mqtt==1.6.1
 
 # Add user `docker`, set password to `docker` and add it to group `sudo`
 RUN useradd -m docker -s /bin/bash && echo "docker:docker" | chpasswd \

There are more breaking changes on 2.0.0, so I'd do a thorough analysis on the impact before upgrading the library. See https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html

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

Successfully merging this pull request may close these issues.

2 participants