mirror of
https://github.com/nodemcu/nodemcu-firmware.git
synced 2025-01-16 20:52:57 +08:00
e547c2a094
I've not been able to get the mqtt `connfail` callback to work. I'm consistently receiving `method not supported` errors: ``` application.lua:53: method not supported stack traceback: [C]: in function 'on' application.lua:53: in main chunk [C]: in function 'dofile' init.lua:18: in function <init.lua:6> ``` Example code: ``` function on_connection_failed(client, reason) print("mqtt connection failed: " .. reason) end m:on("connfail", on_connection_failed) ``` I believed this to be caused by the incorrect length comparison for `connfail` that is updated here. Once I changed that, the error went away, however the callback was never called. I believe the callback was never called because of an incorrect assignment. However, I saw this somewhat confusing description in the docs so this assignment may be expected? > The second (failure) callback aliases with the "connfail" callback available through :on(). (The "offline" callback is only called after an already established connection becomes closed. If the connect() call fails to establish a connection, the callback passed to :connect() is called and nothing else.)