Open olonsoft opened 4 years ago
Port 1880 is the web interface of nodered not the MQTT port so that is why...
The crash should not happen, but it in normal situation it will be fine...
The crash should not happen, but it in normal situation it will be fine...
This crash happened in my application and I couldn't find what was wrong until I noticed the wrong port. Then I run the basic example to be sure that was not my code's bug. I hope this to be fixed soon.
Is it possible to decode the stack trace? I'm quite interested in how this happens. I can't reproduce.
The code is this:
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>
#define WIFI_SSID "Support"
#define WIFI_PASSWORD "12345678"
#define MQTT_HOST IPAddress(192, 168, 19, 10)
#define MQTT_PORT 1880
AsyncMqttClient mqttClient;
Ticker mqttReconnectTimer;
WiFiEventHandler wifiConnectHandler;
WiFiEventHandler wifiDisconnectHandler;
Ticker wifiReconnectTimer;
void connectToWifi() {
Serial.println("Connecting to Wi-Fi...");
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
}
void connectToMqtt() {
Serial.println("Connecting to MQTT...");
mqttClient.connect();
}
void onWifiConnect(const WiFiEventStationModeGotIP& event) {
Serial.println("Connected to Wi-Fi.");
connectToMqtt();
}
void onWifiDisconnect(const WiFiEventStationModeDisconnected& event) {
Serial.println("Disconnected from Wi-Fi.");
mqttReconnectTimer.detach(); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
wifiReconnectTimer.once(2, connectToWifi);
}
void onMqttConnect(bool sessionPresent) {
Serial.println("Connected to MQTT.");
Serial.print("Session present: ");
Serial.println(sessionPresent);
uint16_t packetIdSub = mqttClient.subscribe("test/lol", 2);
Serial.print("Subscribing at QoS 2, packetId: ");
Serial.println(packetIdSub);
mqttClient.publish("test/lol", 0, true, "test 1");
Serial.println("Publishing at QoS 0");
uint16_t packetIdPub1 = mqttClient.publish("test/lol", 1, true, "test 2");
Serial.print("Publishing at QoS 1, packetId: ");
Serial.println(packetIdPub1);
uint16_t packetIdPub2 = mqttClient.publish("test/lol", 2, true, "test 3");
Serial.print("Publishing at QoS 2, packetId: ");
Serial.println(packetIdPub2);
}
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
Serial.println("Disconnected from MQTT.");
if (WiFi.isConnected()) {
mqttReconnectTimer.once(2, connectToMqtt);
}
}
void onMqttSubscribe(uint16_t packetId, uint8_t qos) {
Serial.println("Subscribe acknowledged.");
Serial.print(" packetId: ");
Serial.println(packetId);
Serial.print(" qos: ");
Serial.println(qos);
}
void onMqttUnsubscribe(uint16_t packetId) {
Serial.println("Unsubscribe acknowledged.");
Serial.print(" packetId: ");
Serial.println(packetId);
}
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
Serial.println("Publish received.");
Serial.print(" topic: ");
Serial.println(topic);
Serial.print(" qos: ");
Serial.println(properties.qos);
Serial.print(" dup: ");
Serial.println(properties.dup);
Serial.print(" retain: ");
Serial.println(properties.retain);
Serial.print(" len: ");
Serial.println(len);
Serial.print(" index: ");
Serial.println(index);
Serial.print(" total: ");
Serial.println(total);
}
void onMqttPublish(uint16_t packetId) {
Serial.println("Publish acknowledged.");
Serial.print(" packetId: ");
Serial.println(packetId);
}
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();
wifiConnectHandler = WiFi.onStationModeGotIP(onWifiConnect);
wifiDisconnectHandler = WiFi.onStationModeDisconnected(onWifiDisconnect);
mqttClient.onConnect(onMqttConnect);
mqttClient.onDisconnect(onMqttDisconnect);
mqttClient.onSubscribe(onMqttSubscribe);
mqttClient.onUnsubscribe(onMqttUnsubscribe);
mqttClient.onMessage(onMqttMessage);
mqttClient.onPublish(onMqttPublish);
mqttClient.setServer(MQTT_HOST, MQTT_PORT);
connectToWifi();
}
void loop() {
}
Stack trace decoded:
Exception Cause: 28 [LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads]
0x402034cf: AsyncMqttClient::_onData(AsyncClient*, char*, unsigned int) at ??:?
0x402026d0: std::_Function_base::_Base_manager<std::_Bind<std::_Mem_fn<void (AsyncMqttClient::*)(unsigned short)> (AsyncMqttClient*, std::_Placeholder<1>)> >::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at ??:?
0x402081d8: std::_Function_handler<void (unsigned short), std::_Bind<std::_Mem_fn<void (AsyncMqttClient::*)(unsigned short)> (AsyncMqttClient*, std::_Placeholder<1>)> >::_M_invoke(std::_Any_data const&, unsigned short) at ??:?
0x4020367c: AsyncMqttClient::_onPubComp(unsigned short) at ??:?
0x401002d4: millis at ??:?
0x4010363c: lmacProcessTXStartData at ??:?
0x401002d4: millis at ??:?
0x4020351c: std::_Function_handler<void (void*, AsyncClient*, void*, unsigned int), AsyncMqttClient::AsyncMqttClient()::{lambda(void*, AsyncClient*, void*, unsigned int)#6}>::_M_invoke(std::_Any_data const&, void*, AsyncClient*, void*, unsigned int) at AsyncMqttClient.cpp:?
0x4020759a: AsyncClient::_recv(std::shared_ptr<ACErrorTracker>&, tcp_pcb*, pbuf*, long) at ??:?
0x4000050c: ?? ??:0
0x40207852: AsyncClient::_s_recv(void*, tcp_pcb*, pbuf*, long) at ??:?
0x402120d0: tcp_input at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/core/tcp_in.c:501 (discriminator 1)
0x401009de: malloc at ??:?
0x40217b3e: ip4_input at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/core/ipv4/ip4.c:1467
0x401009a7: free at ??:?
0x40229d20: ppRecycleRxPkt at ??:?
0x4020ed6d: ethernet_input_LWIP2 at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/lwip2-src/src/netif/ethernet.c:188
0x4020eb90: esp2glue_ethernet_input at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-lwip/lwip-git.c:469
0x402341ca: ethernet_input at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:365
0x402341db: ethernet_input at /home/gauchard/dev/esp8266/esp8266/tools/sdk/lwip2/builder/glue-esp/lwip-esp.c:373
0x4022994b: ppPeocessRxPktHdr at ??:?
0x4022f9e3: ets_snprintf at ??:?
0x40000f49: ?? ??:0
0x40000f49: ?? ??:0
0x40000e19: ?? ??:0
0x40001878: ?? ??:0
0x4010482d: call_user_start_local at ??:?
0x40104833: call_user_start_local at ??:?
0x4023eb48: sleep_reset_analog_rtcreg_8266 at ??:?
0x4010000d: call_user_start at ??:?
0x40240000: ?? ??:0
0x4022aaa7: pp_attach at ??:?
0x4022aaf6: pp_attach at ??:?
0x401015cf: ppCalFrameTimes at ??:?
0x4022383c: ieee80211_setup_ratetable at ??:?
0x40229bb3: ppTxPkt at ??:?
0x4021db7b: ieee80211_send_probereq at ??:?
0x4021f9bb: scan_remove_probe_ssid at ??:?
0x4021f58c: scan_start at ??:?
0x40221bec: cnx_start_handoff_cb at ??:?
0x40105111: ets_timer_arm_new at ??:?
0x401001dc: ets_post at ??:?
0x401018c5: rcUpdateTxDone at ??:?
0x40221bec: cnx_start_handoff_cb at ??:?
0x40101490: pp_post at ??:?
0x401001dc: ets_post at ??:?
0x401018c5: rcUpdateTxDone at ??:?
0x40101490: pp_post at ??:?
0x4010472f: lmacTxFrame at ??:?
0x40101490: pp_post at ??:?
0x4010390a: lmacRecycleMPDU at ??:?
0x401001dc: ets_post at ??:?
0x401001dc: ets_post at ??:?
0x40103d7b: lmacRecycleMPDU at ??:?
0x4010363c: lmacProcessTXStartData at ??:?
0x40101490: pp_post at ??:?
0x40104747: lmacRxDone at ??:?
0x4010202b: rcReachRetryLimit at ??:?
0x4010220c: rcReachRetryLimit at ??:?
0x401026ce: wDev_ProcessFiq at ??:?
0x4000050c: ?? ??:0
0x401023f0: wDev_ProcessFiq at ??:?
0x40100ca4: cont_wrapper at ??:?
0x40205977: loop_task(ETSEventTag*) at core_esp8266_main.cpp:?
0x40100ca4: cont_wrapper at ??:?
0x40205ac4: loop_wrapper() at core_esp8266_main.cpp:?
0x40204d8c: HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
0x40204d98: HardwareSerial::write(unsigned char const*, unsigned int) at ??:?
0x40204d00: AsyncMqttClientInternals::UnsubAckPacket::UnsubAckPacket(AsyncMqttClientInternals::ParsingInformation*, std::function<void (unsigned short)>) at ??:?
0x40207f40: std::_Function_handler<void (unsigned short), void (*)(unsigned short)>::_M_invoke(std::_Any_data const&, unsigned short) at ??:?
0x40207f54: std::_Function_base::_Base_manager<void (*)(unsigned short)>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at ??:?
0x4020104a: connectToWifi() at ??:?
0x40207f54: std::_Function_base::_Base_manager<void (*)(unsigned short)>::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at ??:?
0x4020163f: setup at ??:?
0x401001dc: ets_post at ??:?
0x401001fd: esp_schedule at ??:?
0x40205aed: loop_wrapper() at core_esp8266_main.cpp:?
Today while testing the "FullyFeatured-ESP8266.ino" example, I made a mistake and instead of using port 1883, I set 1880 where my node-red is running. The program crashes:
When I set port 1883 it works. When I also set any other not used port, it normally disconnects.