Fipy, umqtt.simple library: check_msg() is blocking

  • I'm using the umqtt.simple library to connect to the Azure IoT Hub and can successfully send messages to the topic, but when I call client.check_msg() to check if a message has been sent to the device, it's blocking my code when no message is sent instead of just returning if a message is in the queue or not.

    So when it get stucked at client.check_msg() and then I send a message to the device the message is printed and the code is continued.

    This is my code:

    client = MQTTClient(device_id, hostname, user=username, password=password, ssl=True, port=8883)
    topic = "devices/{device_id}/messages/events/".format(device_id=device_id)
    sub_topic = "devices/{device_id}/messages/devicebound/#".format(device_id=device_id)
    print("Start sending...")
    cntr = 0
    while (True):
        client.publish(topic, "message", qos=1)
        print("message sent\n")
        print("check messages\n")
        client.check_msg()      #At this point it get stucked when no message has been sent to the device

    Hardware: Fipy, Pytrack, NB-IoT is used to connect to the Azure IoT Hub

  • Someone found a workaround - check out this github here:

  • @MarcosC I've had the same issue. The only workaround for me was to use non-SSL that's the only one that appears to work non-blocking.

  • @Mirox , how have you fix this? I have exactly the same issue and cannot fix it. The chec_msg() method get stucked. Thanks!

Pycom on Twitter