UMQTT - mqtt stops publishing after 5 minutes
Hello everyone,
i am using umqtt library to publish some telemetry data to an IoT platform with a pycom microcontroller. But mqtt stops publishing data exact after five minutes even though it is still connected to wlan.
I am sharing the piece of code that calls mqtt client and the library
Connecting wlan:
wlan.connect('my wlan', auth=(None,'my password'), timeout= 50000) #even though i changed this timeout it didnt solve my problem
My credentials (for iot platform)
server = 'my server'
port = 1883
id = 'my id'
pw = ‘acces token’
topic_publish = 'v1/devices/me/telemetry'
dict={}
Creating a client:
Client = MQTTClient(id, server, port, pw, pw)
time.sleep(2)
client.connect()
Publishing in the loop:
While 1
encoded=ujson.dumps(dict)
client.publish(topic_publish, encoded)
time.sleep(1)
Umqtt library:
Thank you all in advance!
umqtt.simple: Fix MQTTClient publish for connection disruption.
Method now handles OSError: -1 after many packets, attempting reconnection.
Issue #754
Modified the MQTTClient publish method to gracefully handle connection disruptions. Previously, the method encountered an OSError: -1 after sending a large number of packets, leading to a disconnection from the server. The updated method now includes error handling to detect this situation and attempts to reconnect before retrying the operation. This enhancement ensures that the client can recover from connection disruptions seamlessly, maintaining stable communication with the server.