hsaturn / TinyMqtt

ESP 8266 / 32 / WROOM Small footprint Mqtt Broker and Client
GNU General Public License v3.0
183 stars 40 forks source link

`mosquitto_pub` fails on 1.0.0 but works on <= 0.9.18 #71

Open richievos opened 1 year ago

richievos commented 1 year ago

I just updated to the 1.0.0 tag in an attempt to resolve some memory leaks I believe are occurring from TinyMqtt. After updating I can no longer connect to TinyMqtt.

Output under 0.9.18:

$ mosquitto_pub -d -h 192.168.0.70 -p 1883 -t foobar -m '{}'
Client null sending CONNECT
Client null received CONNACK (0)
Client null sending PUBLISH (d0, q0, r0, m1, 'foobar', ... (2 bytes))
Client null sending DISCONNECT

Output under 1.0.0:

$ mosquitto_pub -d -h 192.168.0.70 -p 1883 -t execute/measure_alk/manual/next_stepasdf -m '{}'
Client null sending CONNECT
Error: A network protocol error occurred when communicating with the broker.

I'll debug more, but posting in case others see connectivity issues in the meantime.

richievos commented 1 year ago

Works in bf84e29. First stops working in e41452e.

Issue appears to be this this line:

// old
if (keep_alive && (millis() >= alive))
// new
if (keep_alive && (millis() >= alive - 5000))

what's that - 5000 about? Is that something accidentally left in after testing?

richievos commented 1 year ago

I sent a PR removing that -5000: https://github.com/hsaturn/TinyMqtt/pull/72

I'm not sure what that is representing, so I'm not sure how to test ramifications. This version works for me though.

dg6nee commented 1 year ago

I vote a "+1", similar here, I created a fork quite a while ago and addressed the problem of memory leaks due to bad MQTT client handling (AFAIR pr23). This old version works on two of my devices, stable for many weeks. I tried the latest official versions, but these still fail after less than one day. Same symptoms, device is still active (web server still works), but MQTT is dead, does not respond...

hsaturn commented 1 year ago

PR about 5000ms merged