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.loop_forever() causes a crash #747

Closed
fahadalisarwar1 opened this issue Sep 14, 2023 · 2 comments
Closed

client.loop_forever() causes a crash #747

fahadalisarwar1 opened this issue Sep 14, 2023 · 2 comments
Labels
Status: Available No one has claimed responsibility for resolving this issue.

Comments

@fahadalisarwar1
Copy link

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.

@github-actions github-actions bot added the Status: Available No one has claimed responsibility for resolving this issue. label Sep 14, 2023
@petersilva
Copy link
Contributor

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.

@MattBrittan
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Available No one has claimed responsibility for resolving this issue.
Projects
None yet
Development

No branches or pull requests

3 participants