Lopy4 with MQTT having OSError: [Errno 104] ECONNRESET
I'm writing code for a monitoring station. My station (Lopy4) reads both the serial and analog data, stores them in the SD card and displays the real-time data onto an lcd160cr. Now I'm trying to publish the data to the server through MQTT protocol. I tested the example code over there (https://github.com/zhoumaomao11/pycom-libraries/tree/master/examples/mqtt). It worked properly without any problem, but integrating it into my code gives me the error showing below (OSError: [Errno 104] ECONNRESET).
Could anyone give me some instructions and clues? Thank you!
@cmisztur thank you for replying, I put more details.
I think the error is somewhat related to the variable's type.
I define all the MQTT related variables and then pass them to the MQTTclient function. The error messages are always appears.
######## MQTT Variables ######## MQTTbroker = "mqtt.xxxx.io" MQTTclientNam = "demo" MQTTportNum = 1883 MQTTuserNam = "test" MQTTpassWd = "test" MQTTtopic = "test_topic" client = MQTTClient(MQTTclientNam, MQTTbroker, user=MQTTclientNam, password=MQTTpassWd, port=MQTTportNum) client.publish(topic = MQTTtopic , msg = "test data")
However, after I directly define the variables in the MQTT function. I never got the error back. I still do not understand the reason.
client = MQTTClient("demo", "mqtt.xxxx.io", user="test", password="test", port=1883) client.publish(topic = "test_topic", msg = "test data")
I recalled than when playing with Arduino, I have to define the variables as pointer of the char (char*). I'm not sure my inference is correct or not. Please correct me if you have the answer.
Gotta see more code.