Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

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

    Scheduled Pinned Locked Moved Issues & Bugs
    fipymqttmqtt bugsazurenb-iot
    4 Posts 4 Posters 207 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M Offline
      Mirox
      last edited by

      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)
      
      client.set_callback(sub_cb)
      
      client.connect()
      
      client.subscribe(sub_topic)
      
      print("subscribed")
      
      time.sleep(1)
      
      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
          cntr+=1
          time.sleep(20)
      
      

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

      1 Reply Last reply Reply Quote 2
      • M Offline
        MarcosC
        last edited by

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

        R 1 Reply Last reply Reply Quote 0
        • R Offline
          randomrnti @MarcosC
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • A Offline
            Alan Zhang
            last edited by

            Someone found a workaround - check out this github here: https://github.com/pycom/pycom-micropython-sigfox/issues/424

            1 Reply Last reply Reply Quote 1

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            • 1 / 1
            • First post
              Last post

            Pycom on Twitter

            Pycom