esp32-mqtt
esp32-mqtt copied to clipboard
Compilation error - undeclared struct field "reconnect_cb"
Working with da0e976, using espmqtt component @ https://github.com/tuanpmt/espmqtt/commit/2967332b95454d4b53068a0d5484ae60e312eb12
IDF https://github.com/espressif/esp-idf/commit/843159b0d7284ba560345af312a1e7f8b14d19e7
Compilation fails with:
/Users/david/esp32/projects/esp32-mqtt/main/./app_main.c:97:5: error: unknown field 'reconnect_cb' specified in initializer
https://github.com/tuanpmt/espmqtt/blob/2967332b95454d4b53068a0d5484ae60e312eb12/include/mqtt.h#L40 does not declare a field "reconnect_cb" - perhaps the espmqtt component has not been pushed by the author to GitHub at the same time as this project, resulting in a mismatched submodule?
Workaround is obviously to comment out the line @ https://github.com/tuanpmt/esp32-mqtt/blob/da0e9769c979bf1bc91fd979f65431ac3b4536c2/main/app_main.c#L97
anyone got the solution yet? facing the same problem
In the end I just commented it out in my own fork.
To be frank, I've stopped using this library because it has a fundamental flaw with the way it handles TCP streams, which leads to lost messages. Unless you're sending occasional one-off messages, I'd be wary. It could probably be fixed fairly easily, by treating the TCP connection properly as a stream rather than incorrectly as a packet source, however it was easier for me to find another library than fix it myself.
However this library does provide a security implementation, so I may return to it at some stage. It's just a shame the original author doesn't reliably respond here.
@DavidAntliff I see, did you manage to solve this "reconnect" issue in the end? Thanks for the reply!
I don't recall exactly but I think I ended up making a call to connect (or at least setting a flag to retry a connect) in the disconnect handler.
@leonpenang set auto_reconnect
variable in mqtt_settings
. It solves the issue of re-connection. However if you need reconnect
callback then you need to add it in mqtt_settings
definition.