njouanin / hbmqtt

MQTT client/broker using Python asynchronous I/O

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mqtt_ping(): Task was destroyed but it is pending

JANEZMY opened this issue · comments

I use HBMQTT as a client. When sending PINGREQ, the broker sometimes shows that "Client has exceeded timeout, disconnecting", and the client's terminal is: "Task was destroyed but it is pending... pending coro=ClientProtocalHandler.mqtt_ping()"

Test python:

import asyncio

from hbmqtt.client import MQTTClient

@asyncio.coroutine
def test_coro():
    config = {
        'keep_alive': 6,
        'ping_delay': 3,
        'default_qos': 0,
        'default_retain': False,
        'auto_reconnect': True,
        'reconnect_max_interval': 5,
        'reconnect_retries': 3
    }
    C = MQTTClient(config=config)
    yield from C.connect('ws://localhost:9013/', cleansession=False)
    tasks = [
        asyncio.ensure_future(C.publish('a/b', b'TEST MESSAGE WITH QOS_0'))
    ]
    yield from asyncio.wait(tasks)

if __name__ == '__main__':
    formatter = "[%(asctime)s] %(name)s {%(filename)s:%(lineno)d} %(levelname)s - %(message)s"
    asyncio.ensure_future(test_coro())
    asyncio.get_event_loop().run_forever()

Broker print:

1559120457: Client hbmqtt/GRbE:bHJ=vDPEI?\ has exceeded timeout, disconnecting.
1559120458: Socket error on client hbmqtt/GRbE:bHJ=vDPEI?\, disconnecting.
1559120459: Client hbmqtt/GRbE:bHJ=vDPEI?\ disconnected.
1559120459: New client connected from 127.0.0.1 as hbmqtt/GRbE:bHJ=vDPEI?\ (c0, k3).
1559120459: Sending CONNACK to hbmqtt/GRbE:bHJ=vDPEI?\ (1, 0)
1559120462: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120462: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120465: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120465: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120468: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120468: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120471: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120471: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120474: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120474: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120477: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\
1559120477: Sending PINGRESP to hbmqtt/GRbE:bHJ=vDPEI?\
1559120480: Client hbmqtt/GRbE:bHJ=vDPEI?\ has exceeded timeout, disconnecting.
1559120481: Socket error on client hbmqtt/GRbE:bHJ=vDPEI?\, disconnecting.
1559120482: Client hbmqtt/GRbE:bHJ=vDPEI?\ disconnected.
1559120482: New client connected from 127.0.0.1 as hbmqtt/GRbE:bHJ=vDPEI?\ (c0, k3).
1559120482: Sending CONNACK to hbmqtt/GRbE:bHJ=vDPEI?\ (1, 0)
1559120485: Received PINGREQ from hbmqtt/GRbE:bHJ=vDPEI?\

Client Terminal Error:

Task was destroyed but it is pending!
task: <Task pending coro=<ClientProtocolHandler.mqtt_ping() done, defined at /usr/local/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/client_handler.py:155> wait_for=<Future cancelled>>
Task was destroyed but it is pending!
task: <Task pending coro=<ClientProtocolHandler.mqtt_ping() done, defined at /usr/local/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/client_handler.py:155> wait_for=<Future cancelled>>
Disconnected from broker
Disconnected from broker
Disconnected from broker
Task was destroyed but it is pending!
task: <Task pending coro=<ClientProtocolHandler.mqtt_ping() done, defined at /usr/local/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/client_handler.py:155> wait_for=<Future cancelled>>
Task was destroyed but it is pending!
task: <Task pending coro=<ClientProtocolHandler.mqtt_ping() done, defined at /usr/local/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/client_handler.py:155> wait_for=<Future cancelled>>
Disconnected from broker
Disconnected from broker
Disconnected from broker
Task was destroyed but it is pending!
task: <Task pending coro=<ClientProtocolHandler.mqtt_ping() done, defined at /usr/local/lib/python3.6/site-packages/hbmqtt/mqtt/protocol/client_handler.py:155> wait_for=<Future cancelled>>