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 event source seems to be using deprecated connection methods #3

Closed
jpmens opened this issue Oct 1, 2023 · 4 comments · Fixed by #6 · May be fixed by #5
Closed

mqtt event source seems to be using deprecated connection methods #3

jpmens opened this issue Oct 1, 2023 · 4 comments · Fixed by #6 · May be fixed by #5

Comments

@jpmens
Copy link
Contributor

jpmens commented Oct 1, 2023

I ran pip install aiomqtt and got aiomqtt-1.2.1 installed which, when used from the mqtt event source reports:

2023-10-01 09:42:51,286 - mqtt - WARNING - The manual `connect` and `disconnect` methods are deprecated and will be removed in a future version. The preferred way to connect and disconnect the client is to use the context manager interface via `async with`. In case your use case needs to connect and disconnect manually, you can call the context manager's `__aenter__` and `__aexit__` methods as an escape hatch instead. `__aenter__` is equivalent to `connect`. `__aexit__` is equivalent to `disconnect` except that it forces disconnection instead of throwing an exception in case the client cannot disconnect cleanly. `__aexit__` expects three arguments: `exc_type`, `exc`, and `tb`. These arguments describe the exception that caused the context manager to exit, if any. You can pass `None` to all of these arguments in a manual call to `__aexit__`.
jpmens added a commit to jpmens/kubealex.eda that referenced this issue Oct 1, 2023
This appears to address kubealex#3 in as much as it works and the warning I
reported there is silenced. Note that this patch contains the PR I
submitted in kubealex#4.
	closes kubealex#3
@kurokobo
Copy link

kurokobo commented Jan 17, 2024

@kubealex @jpmens
F.Y.I., aiomqtt 2.0.0 had been released on 16 Jan, and in 2.0.0 connect (and disconnect) method completely removed:
https://github.com/sbtinstruments/aiomqtt/blob/main/CHANGELOG.md

So kubealex.eda.mqtt 1.0.7 no longer works with aiomqtt 2.0.0.

2024-01-17 13:24:09,200 - ansible_rulebook.engine - INFO - Calling main in kubealex.eda.mqtt
2024-01-17 13:24:09,201 - ansible_rulebook.engine - ERROR - Source error 'Client' object has no attribute 'connect'
2024-01-17 13:24:09,201 - ansible_rulebook.engine - ERROR - Shutting down source: kubealex.eda.mqtt error : 'Client' object has no attribute 'connect'

As a workaround, we have to install 1.x of aiomqtt to make kubealex.eda.mqtt work.

@kubealex
Copy link
Owner

Thanks a lot for pointing that out @jpmens and @kurokobo!

I just tested and released v1.0.8 that is working like a charm, do you mind giving it a try @kurokobo?

Thank you!

@kubealex kubealex reopened this Jan 17, 2024
@kurokobo
Copy link

@kubealex
Thanks for rapid update, I've tested kubealex.eda.mqtt on kubealex.eda==1.0.8 with aiomqtt==2.0.0 and confirmed that it works well without any errors nor warnings.
I think this issue can be closed. Thanks!

@kubealex
Copy link
Owner

The closing comment was lost in space :D Closing as discussed, thanks @kurokobo for the tests!

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