-
Notifications
You must be signed in to change notification settings - Fork 721
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
paho-mqtt-2.0.0 client issue #814
Comments
I have this exact problem with raspberry pi Bullseye 32 bit. |
I believe you didn't provided the full traceback. Please report full traceback when submitting bug report. I believe something similar to the following is missing:
Please read https://eclipse.dev/paho/files/paho.mqtt.python/html/migrations.html |
mqttc = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1) fixed for me :) Problem was that the AttributeError: 'Client' object has no attribute '_sock' was coming out in console and the |
I also got into the same error. Is it a good idea to provide a default value for API_VERSION for avoiding the AttributeError? Any thoughts? |
@PierreF this is going to come up a lot (there are already two questions on stack overflow). I wonder if it's worth adding something at the start of the readme, and perhaps a pinned issue? Most tutorials just say to run On a linked note the error says |
I think of this... but it means each time the default change it will cause a (potentially rather silent) breaking change.
yeah... I moved the file and forget to update that link. I'll also try to see if we could avoid the 2nd error (the delete of |
yes, if the first real cause was the only error - be much quicker for users to resolve :) could the default not just be V1? |
This is an option, however I wonder if doing so might just prolong the pain... With the current solution (deliberately breaking old code) a lot of users are going to hit this message in the near future, learn about the V2 release, and update their code (and, hopefully, tutorials etc). We can ensure the solution is highly visible and attempt to get popular tutorials updated. If the library defaults to V1 it's likely that a lot of users will not really notice the V2 release. Whilst this would result in less immediate pain, it seems likely to result in ongoing confusion as users copy/paste incompatible code (e.g. copying portions of examples included in this repo into their V1 code bases). This will result in somewhat confusing runtime errors, and it's likely to be more difficult to find solutions (the current message is pretty clear, and the stack overflow question has 300+ views in under a day). This was always going to be a painful change; but one I was really happy to see Pierre make (the V1 API was confusing; particularly the way the API differed depending upon whether you were connected via V3 or V5!). |
Noted as workaround in PR eclipse-paho/paho.mqtt.python#814
Running this gives me:
I'm using 2.0.0 version
|
@fuomag9 Your error seems perfectly normal to me, since you do not provide the require argument But I don't understand why you don't use standard way to create a instance ?
This point don't is not related to this issue, it's another issue. Please open a new issue if the problem persist. |
As someone who just ran into this, I would like to add my 2 cents. My problem with the approach taken is that it makes supporting older and newer versions more difficult and it's a bit ugly. For example, now I have to use the library like this:
This is pretty awkward. IMO and actually encourages people to just use VERSION1 and not update to the new ones. I have 6 or 7 apps I need to update to look like this now. I would have appreciated this approach:
That way the older arguments can be completely deprecated at a later time, but that gives people time to adjust. As it stands right now, everybody has to make a change right now as it's broken. The point of deprecation warnings is to give people a window to make the changes so that applications do not break. The approach taken defeats this purpose. If the approach I described above was taken, it would have been a lot more smooth, especially since adjusting the callbacks is not exactly difficult. Why would I really want to make 2 changes at different times when only one is needed? For example, this is all I could have needed in an app I updated just now to support both:
If the approach seems reasonable to you I would be happy to make a PR. |
#831 already do some step to reduce the breaking changes. On your suggestion, I do have few remark:
(*): I'm not really sure how we could detect a v2 callback, this seems tricky to define. I believe the followings are version 2:
Note that the difference between the following two is very tiny:
If I understand right your use-case, it's on a application where a 3rd party library (or just something not easy to upgrade) create the paho client, but you can upgrade the callback ? So you suggestion seems a good idea, but I think we will need an option to skip version detection and choose a specific version. |
@PierreF When I made my suggestion I didn't realize that MQTT5 changed the values of the reason codes. That is unfortunate and certainly makes the heuristic a bit more difficult. However, it seems the existence of the properties field as a positional or keyword arg may indicate that it was intended for either the 1.x release with MQTT5 support or the 2.x release, in which case the However, I would suspect that most instances of the connect callbacks are either ignoring But yeah, thanks to the reason code change, it can't actually be perfect, and an override would probably be warranted. I still think the notion of a callback API version in this manner may make it more complicated than it needs to be. However, it might make more sense if that was defined explicitly via a namespace, for example:
And then for each time it needs to perform a callback it could check for a v2 callback, then a v1 callback. That would be a much bigger change however and look less ergonomic. |
Well, a lot of existing projects are broken now. How should a user without programming skills should handle this?! These changes are the badest idea ever - sorry to be honest. |
For example notus-scanner and ospd-openvas, both of GVM, are broken. That is bad coding style. Changes must maintain "legacy" intefaces, i.e. the V1 must work without any knowledge of V2. |
I think, it's more important for the whole community to have stable code than beeing always informed about new features. A new feature is worthless if something is broken. And for sure, you have many ways of informing users of new attributes ... |
To be honest an end-user is not interested in any APIs, versions, super-dupa-new features. It should just work and they want to have their values in their MQTT brokers. And that is what V1 did now for years. Maybe V2 is really a big step forward, but only programmers will be interested in that. All other just want to have a running system. Another broken project now: flyte/mqtt-io#348 The authors now discuss to change their whole (!!!) code basis just to be comptatible with paho-mqtt V2. What a waste of limited ressources... |
In that situation GVM is part of Kali Linux using the pre-packaged Python libraries. |
Did I see that correctly? |
2.1.0 fixes this for me |
Bug Description
When running the script with paho-mqtt 2.0.0 and initializing the Client(), an AttributeError occurs: 'Client' object has no attribute '_sock'. However, when changing to paho-mqtt 1.6.1, everything works fine.
Environment
Logs
Exception ignored in: <function Client.del at 0x7f23e91e2040>
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 874, in del
self._reset_sockets()
File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1133, in _reset_sockets
self._sock_close()
File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1119, in _sock_close
if not self._sock:
AttributeError: 'Client' object has no attribute '_sock'
The text was updated successfully, but these errors were encountered: