-
Notifications
You must be signed in to change notification settings - Fork 3
Description
PubSubClient gets disconnected from MQTT broker from time to time (time periods differs significantly - from few minutes to couple of hours).
Looks like PubSubClient is sending malformed TCP/MQTT packet which looks like Disconnect Req, but with very high Msg Len. It causes messages afterwards to be treated as continuation of this message. That includes Ping Request message. After "keep alive" timeout (in my case 15sec x2) PubSubClient decides to disconnect as it has not received Ping Response message.
I couldn't find the problem in RoomHub code. It looks like the problem in W5500 hardware or Arduino Ethernet library.
This is important to fix this as it makes using RoomHub with Ethernet connection unstable.
It doesn't influence version with WiFi connection which seems to be stable.
There are tickets created for this issue in PubSubClient and Ethernet library projects:
arduino-libraries/Ethernet#106
knolleary/pubsubclient#639
Ideas to check:
- try to use other versions of Ethernet library (Adafruit/Wiznet)
- replace W5500 with other hardware (are pins available?)
- adding some capacitor in connection
- use asynchronous MQTT library instead of PubSubClient (https://github.com/marvinroger/async-mqtt-client)