-
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
ReasonCode.names is missing a ReasonCode.packet_name #827
Comments
The purpose of I would assume that it does not expose information about the packet type is because it's intention was to communicate the Reason Code (and your use-case was not foreseen). Can you please show how/where you would use the info? |
Sure, for example: if you have a callback on_disconnect and want to print the reason for disconnecting to the log, you currently just get |
The This is why I requested an example; I don't think that making this data more accessible is really going to help you. If you are in the |
As there are mostly more than one packet types possibe per ID (name), having additional info about the reason is helpful to narrow down issues. The easy example of rebooting a mosquitto container is just a placeholder for more complex problems. That the connection was lost is naturally given by the callback. I want to destinguish the reason as best as possible. It is not hurting anyone providing that info, but can help finding causes more easily. The info is already here an just needs to be made available. |
You could do something like this:
Output:
I doubt that a getter will be added to |
I have tested this with The combination:
should be part of the documentation. |
While reading the docs about
ReasonCode.names
at https://eclipse.dev/paho/files/paho.mqtt.python/html/types.html#paho.mqtt.reasoncodes.ReasonCodeI was wondering why the
packet_name
useful to know where things come from is not listed. The only way I found was using https://github.com/eclipse/paho.mqtt.python/blob/master/src/paho/mqtt/reasoncodes.py#L190 (__repr__()
) asgetName()
returns the name only.Using that function gives me
ReasonCode(Disconnect, 'Unspecified error')
which is better than nothing.I also would be happy if
getName()
would return an array where 0 is the name and 1 is the packet_name or another way I can get the packet_name.The text was updated successfully, but these errors were encountered: