knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

Reconnects every 4 hours #1025

Closed Danny24 closed 10 months ago

Danny24 commented 10 months ago

Hi,

I am using this library with mosquitto broker. I have a weird issue, I set up setKeepAlive to 10 minutes and I send an "ALIVE" message every 2 minutes. It works just fine keeping the connection open for long time. But exactly every 4 hours the connections disconnects and connects right away releasing the last will message. I run "MQTTclient.loop()" every second to check if there are new messages for the ESP8266. I think this is fine, but for some weird reason the connection is lost every 4 hours and is back right away.

Does somebody also experienced this? How do you fix it? Thanks

Danny24 commented 10 months ago

I answer myself, problem solved. I was reutilizing the wifi constructor and apparently MQTT doesn't like to share with HTTP requests. I made MQTT his own wifi constructor and the connection problem go away.

thaoton-33 commented 7 months ago

Could you describe in more detail?