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

client._on_connect exception rc type error #58

Closed
jschlyter opened this issue May 4, 2021 · 2 comments · Fixed by #59
Closed

client._on_connect exception rc type error #58

jschlyter opened this issue May 4, 2021 · 2 comments · Fixed by #59

Comments

@jschlyter
Copy link
Contributor

It seems that https://github.com/sbtinstruments/asyncio-mqtt/blob/master/asyncio_mqtt/client.py#L387 may yield an error as rc is paho.mqtt.reasoncodes.ReasonCodes and not an integer?

asyncio-mqtt==0.9.0
paho-mqtt==1.5.1
@frederikaalund
Copy link
Member

Hi Jakob, thanks for raising this issue. Let me have a look. :)

I think you're right. The following is an excerpt from paho-mqtt:

    def on_connect(self, func):
        """ Define the connect callback implementation.
        Expected signature for MQTT v3.1 and v3.1.1 is:
            connect_callback(client, userdata, flags, rc, properties=None)
        and for MQTT v5.0:
            connect_callback(client, userdata, flags, reasonCode, properties)
        client:     the client instance for this callback
        userdata:   the private user data as set in Client() or userdata_set()
        flags:      response flags sent by the broker
        rc:         the connection result
        reasonCode: the MQTT v5.0 reason code: an instance of the ReasonCode class.
                    ReasonCode may be compared to interger.

The connect callback gets:

  • an int for MQTT v3.1 and V3.1.1
  • a ReasonCode for MQTT v5.0

We should update the types to reflect this. Do you want to submit a pull request?

Note that ReasonCode is comparable to int.

@jschlyter
Copy link
Contributor Author

And thanks for keeping me honest - never report a bug without a PR is a golden rule! :-)

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 a pull request may close this issue.

2 participants