Description
Original issue reported by @cimba007 on mycontroller-org/mycontroller-v1-legacy#425
If I upload a new sketch the mqtt-client does not logoff from the mqtt-server (buildin mycontroller).
On next sketch run presentation is skipped:
MC[I]: Booting ESP8266 device...<\n>
MC[I]: WIFI not connected, trying connection...<\n>
MC[D]: Searching BSSID for ssid:[FRITZ!Box Fon WLAN 7390]<\n>
MC[D]: Found BSSID[] for ssid:[FRITZ!Box Fon WLAN 7390], RSSI:[-62 -dBm, 76 %]<\n>
MC[D]: Selected bssid:[]<\n>
MC[I]: Connecting to WiFi with ssid[FRITZ!Box Fon WLAN 7390] and with password.....OK<\n>
MC[I]: WiFi BSSID:[], RSSI:[-68 dBm, 64 %], IP:[], StatusCode:[3]<\n>
MC[D]: WiFi connection status: Connected<\n>
MC[I]: Configuration(NodeEUI:[], Mqtt{mDNS-status:[0], Server:[], Port:[], FeedId:[esp], User:[]})<\n>
MC[D]: Attempting MQTT connection...<\n>
MC[I]: MQTT settings(Broker:[], Port:[])<\n>
MC[I]: MQTT authenticating as user:[]<\n>
MC[I]: MQTT connection failed, rc=-4<\n>
MC[D]: Try again in 3 seconds<\n>
MC[I]: Initialization done...<\n>
MC[I]: MQTT failed! Retryting to connect...<\n>
MC[D]: WiFi connection status: Connected<\n>
MC[D]: Attempting MQTT connection...<\n>
MC[I]: MQTT settings(Broker:[], Port:[])<\n>
MC[I]: MQTT authenticating as user:[]<\n>
MC[I]: MQTT connected :)<\n>
MC[I]: MQTT topic subscribed:[in_esp/ESP_C0DE98/#]<\n>
@cimba007 Could you please elaborate this issue?
I will try .. assume I upload my sketch to the esp8266 and everything is working as expected.
Now I want to upload a new sketch .. the upload process resets the esp8266 and leaves an open mqtt-connection on the broker (the client just vanished and did no proper logoff). Now the new sketch is uploaded .. and tries to connect again to the broker.
MC[D]: Attempting MQTT connection...<\n>
MC[I]: MQTT settings(Broker:[], Port:[])<\n>
MC[I]: MQTT authenticating as user:[]<\n>
MC[I]: MQTT connection failed, rc=-4<\n>
MC[D]: Try again in 3 seconds<\n>
The connection fails .. but succeeds after 3 seconds on the next retry.
MyControllerDevice/MyController.cpp
Line 121 in 95ea3ea
The code presented here will be skipped ...
if(mqttClient.connected()){
before();
sendRSSI();
sendStatistics();
mcPresentation();
}
When the yellow part is called
The only check and chance to run
if(mqttClient.connected()){
before();
sendRSSI();
sendStatistics();
mcPresentation();
}
is gone.
I hope this made it a little bit more clear.