Open BruceAKABear opened 1 year ago
I have meet one strange problem, esp8266 call connected() methd will return false every 30 min actually the hartbeat is still working, in my logic when connected() return I will reboot whole system. why connected() will return false?
` hearbeat:
2023-07-05T10:45:47+08:00 [MQTT] 13388860@10.5.171.61:54257 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0) 2023-07-05T10:45:47+08:00 [MQTT] 13388860@10.5.171.61:54257 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0)
my logic in connect:
2023-07-05T10:45:57+08:00 [MQTT] 13388860@10.5.171.61:53948 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0),ClientId=13388860, ProtoName=MQTT, ProtoVsn=4, CleanStart=true,
`
my logic in loop:
void loop() { if (WiFi.status() != WL_CONNECTED) { connectWifi(); } else { if (!mqttClient.connected()) { connectMqtt(); } } mqttClient.loop(); } `
Check your wifi is stable.
I have meet one strange problem, esp8266 call connected() methd will return false every 30 min actually the hartbeat is still working, in my logic when connected() return I will reboot whole system. why connected() will return false?
` hearbeat:
2023-07-05T10:45:47+08:00 [MQTT] 13388860@10.5.171.61:54257 msg: mqtt_packet_received, packet: PINGREQ(Q0, R0, D0) 2023-07-05T10:45:47+08:00 [MQTT] 13388860@10.5.171.61:54257 msg: mqtt_packet_sent, packet: PINGRESP(Q0, R0, D0)
my logic in connect:
2023-07-05T10:45:57+08:00 [MQTT] 13388860@10.5.171.61:53948 msg: mqtt_packet_received, packet: CONNECT(Q0, R0, D0),ClientId=13388860, ProtoName=MQTT, ProtoVsn=4, CleanStart=true,
`
my logic in loop:
`
void loop() { if (WiFi.status() != WL_CONNECTED) { connectWifi(); } else { if (!mqttClient.connected()) { connectMqtt(); } } mqttClient.loop(); } `