nodemcu / nodemcu-firmware

Lua based interactive firmware for ESP8266, ESP8285 and ESP32
https://nodemcu.readthedocs.io
MIT License
7.66k stars 3.12k forks source link

mqtt:unsubscribe dumps #1304

Closed dvv closed 8 years ago

dvv commented 8 years ago
c = mqtt.Client("foo", 120)
c:connect("192.168.1.4", 1883, 0)
-- NB: http://nodemcu.readthedocs.io/en/dev/en/modules/mqtt/#syntax_7
c:unsubscribe("foo")
-- PANIC: unprotected error in call to Lua API (attempt to call a nil value)
FrankX0 commented 8 years ago

You are unsubscribing from a topic you did not subscribe to first. And you seem to mix the client name (foo) and a topic (foo).

dvv commented 8 years ago

I described the sequence on pretty valid calls which led to sudden reset.

devsaurus commented 8 years ago

Thanks for reporting @dvv. It appears that the unsubscribe callback is triggered without being initialized earlier. mud->cb_unsuback_ref is only set when c:unsubscribe() provides a callback function - otherwise it remains uninitialized. I'll dig into a fix.

pjsg commented 8 years ago

Fix merged to dev