njouanin / hbmqtt

MQTT client/broker using Python asynchronous I/O
MIT License
800 stars 187 forks source link

"'NoneType' object has no attribute 'delivered_message_queue'" when losing connection #104

Open hongquan opened 6 years ago

hongquan commented 6 years ago

Steps to reproduce

  1. Run a script which use hbmqtt, connecting to Mosquitto broker.
  2. Restart the broker, to cause a temporary disconnection.

What happened:

hbmqtt failed:

2018-02-01 14:22:46 INFO:__main__: MQTT payload from daothanh/r2/ds/02: bytearray(b'1')
Disconnected from broker
Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/quan/Works/AgriConnect/PlantingHouse/controlview/collector/__main__.py", line 228, in <module>
    loop.run_until_complete(asyncio.gather(*coroutines))
  File "uvloop/loop.pyx", line 1364, in uvloop.loop.Loop.run_until_complete
  File "/home/quan/Works/AgriConnect/PlantingHouse/controlview/collector/__main__.py", line 199, in collect_mqtt
    message = await mqtt_client.deliver_message(MQTT_TIMEOUT)
  File "/home/quan/Works/Envs/agri/lib/python3.6/site-packages/hbmqtt/client.py", line 335, in deliver_message
    return deliver_task.result()
  File "/home/quan/Works/Envs/agri/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/handler.py", line 466, in mqtt_deliver_next_message
    message = yield from self.session.delivered_message_queue.get()
AttributeError: 'NoneType' object has no attribute 'delivered_message_queue'

What is expected

hbmqtt should not fail, because it can reconnect the MQTT.

caseybrichardson commented 4 years ago

I have also seen this issue. I'm looking into another issue (#119), and will see if I can figure anything out for this issue as well.

adm78 commented 4 years ago

We are seeing this issue as well with hbmqtt 0.9.6

MikeMint commented 4 years ago

We are seeing this issue as well with hbmqtt 0.9.6

Same problem, same 0.9.6 version