Mqtt publish error

Hi,
I can’t seem to get the MQTT working. I am getting error -22

client = MQTTClient("openmv", "broker.hivemq.com", port=1883)
client.connect()

while (True):
    client.publish("openmv/test", "Hello World!")
    time.sleep_ms(1000)
Traceback (most recent call last):
File "<stdin>", line 29, in <module>
File "mqtt.py", line 148, in publish
OSError: -22
MicroPython: v1.18-omv-r13 OpenMV: v4.3.2 HAL: v1.9.0 BOARD: OPENMV4P-STM32H743
Type "help()" for more information.

Thanks!

That’s usually a problem with the broker, does it work with test.mosquitto.org ?

I get the same error – I did check connectivity through other clients to the hivemq broker, as well as to my own.

I don’t have a WINC shield to test with, can you test this @kwagyeman

Hi Pilot, how can I test this?

@kwagyeman You can just test our built-in mqtt examples, there are some instructions in the comments.

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", "broker.hivemq.com", port=1883)
client.connect()

while (True):
    client.publish("openmv/test", "Hello World!")
    time.sleep_ms(1000)

Thanks!

My board just gets stuff in the:

client = MQTTClient("openmv", "broker.hivemq.com", port=1883)
client.connect()

And doesn’t return.

I don’t get an error 22.

That weird, I am not sure how to troubleshoot this. Thanks for checking though.