We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
here is my code.
mqttc = mqtt.Client() mqttc.on_connect = on_connect mqttc.on_message = on_message mqttc.username_pw_set("fahad", "fahad") rc = mqttc.connect("192.168.2.65", 1883, 60) print(rc) mqttc.subscribe(topics[0], qos=1) mqttc.publish(topics[1], "off", qos=1, retain=True) print("okkkk") mqttc.loop_forever()
As soon as it reaches the lines client.loop_forever(), it crashes with following code.
0 okkkk Traceback (most recent call last): File "/home/h2gremm/mqtt-app/main.py", line 37, in <module> mqttc.loop_forever() File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1756, in loop_forever rc = self._loop(timeout) ^^^^^^^^^^^^^^^^^^^ File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1164, in _loop rc = self.loop_read() ^^^^^^^^^^^^^^^^ File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 1556, in loop_read rc = self._packet_read() ^^^^^^^^^^^^^^^^^^^ File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 2439, in _packet_read rc = self._packet_handle() ^^^^^^^^^^^^^^^^^^^^^ File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3039, in _packet_handle return self._handle_connack() ^^^^^^^^^^^^^^^^^^^^^^ File "/home/h2gremm/mqtt-app/venv/lib/python3.11/site-packages/paho/mqtt/client.py", line 3138, in _handle_connack on_connect( TypeError: on_connect() missing 1 required positional argument: 'return_code'
Can please somebody tell me the reason.
The text was updated successfully, but these errors were encountered:
It's telling you the reason:
TypeError: on_connect() missing 1 required positional argument: 'return_code'
your on_connect() function (which you didn't include) doesn't have the right number of parameters.
Sorry, something went wrong.
Closing this as Peters comment looks good and there has been no activity since. Please feel free to reopen if you are still having issues.
No branches or pull requests
here is my code.
As soon as it reaches the lines client.loop_forever(), it crashes with following code.
Can please somebody tell me the reason.
The text was updated successfully, but these errors were encountered: