MQTT client.check_msg() not working

Hi Team,
I was playing with the examples of Mqtt and facing the issue with the same. The client.check_msg() is not working as expected it is getting automatically stopped and not displaying any kind message even after publishing. I am successfully receiving the message when I am using wait_msg() but it blocks all the other process going on which I dont want. I want to check if their is any message present and then it should print it and if not then it should go ahead and work on its part. Can you please provide some guidance on the issue.

Do you have an example script to show the issue? With the least amount of code?

Hi Kwabena,

I am posting the code in the attachments. Here in the sub.py client.check_msg() is not working for me, I am not getting any message also the count is not getting printed.

################Subscriber Code############

import time, network
from mqtt import MQTTClient

SSID='******' # Network SSID
KEY='******'  # Network key

# Init wlan module and connect to network
print("Trying to connect... (may take a while)...")

wlan = network.WINC()
wlan.connect(SSID, key=KEY, security=wlan.WPA_PSK)

# We should have a valid IP now via DHCP
print(wlan.ifconfig())

client = MQTTClient("openmv", "test.mosquitto.org", port=1883)
client.connect()
message = ''

def callback(topic, msg):
    global message
    message = msg

# must set callback first
client.set_callback(callback)
client.subscribe("openmv/test")
count = 0
while (True):
    client.check_msg() # poll for messages.
    if message!="":
        print(message)
        message =''
    time.sleep_ms(1000)
    print(count)
    count+=1

#############Publisher Code ################

import paho.mqtt.client as mqtt 
import time

mqttBroker ="test.mosquitto.org"
client = mqtt.Client("Publisher")
client.connect(mqttBroker) 


while True:
    msg = input("Enter Your Message:")
    client.publish("openmv/test", msg)
    print("Device-1 : " + msg)

Hi Team,
Is their any update on this issue?

Yes, try the latest development firmware, it should be fixed now.

1 Like

Hi @iabdalkader ,

Could you please confirm which firmware to use for “OpenMV H7 Plus”?

That would be the OPENMV4P

Thank You @iabdalkader. I will try it out.:slightly_smiling_face:

Hi @iabdalkader , the new firmware has resolved the MQTT issue but now whenever I am using sensor it is throwing error
" File “”, line 30, in RuntimeError: Sensor control failed."
Can you please provide any resolution for the same

I have no idea, I don’t know what line 30 is :slight_smile: Please post a new topic and post the code.