ESP8266MQTTClient
ESP8266MQTTClient copied to clipboard
problem Mqtt client ssl
hello i have used this libray but the esp8266 go to crash. can I help me please?
this is the code
`#include <ESP8266MQTTClient.h> #include <ESP8266WiFi.h>
MQTTClient mqtt; String fingerprint = "finger print ";
String host = "192.168.1.227";
// WiFi card example char ssid[] = "gdfgdfgg"; // your SSID char pass[] = "gfdgdfggdfgfdgdgfdgfdgd"; // your SSID Password
void setup() { Serial.begin(115200); WiFi.begin(ssid,pass );
while(WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
mqtt.onSecure([](WiFiClientSecure *client, String host) {
Serial.printf("Verify: %s\r\n", host.c_str());
return client->verify(fingerprint.c_str(), host.c_str());
});
//topic, data, data is continuing
mqtt.onData([](String topic, String data, bool cont) {
Serial.printf("Data received, topic: %s, data: %s\r\n", topic.c_str(), data.c_str());
mqtt.unSubscribe("/qos0");
});
mqtt.onSubscribe([](int sub_id) {
Serial.printf("Subscribe topic id: %d ok\r\n", sub_id);
mqtt.publish("/qos0", "qos0", 0, 0);
});
mqtt.onConnect([]() {
Serial.printf("MQTT: Connected\r\n");
mqtt.subscribe("/qos0", 0);
});
mqtt.begin("mqtts://davide:[email protected]:8883" , {.lwtTopic = "hello", .lwtMsg = "offline", .lwtQos = 0, .lwtRetain = 0});
//mqtt.begin("mqtts://test.mosquitto.org:8883", {.lwtTopic = "hello", .lwtMsg = "offline", .lwtQos = 0, .lwtRetain = 0});
//mqtt.begin("mqtts://user:[email protected]:8883");
//mqtt.begin("mqtts://user:[email protected]:8883#clientId");
}
void loop() { mqtt.handle();`
and this the error log
`Panic C:\Users\davide\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0-rc2\cores\esp8266\abi.cpp:92 __throw_bad_function_call
ctx: cont sp: 3fff0870 end: 3fff0a90 offset: 01b0
stack>>> 3fff0a20: 00000000 00000000 00000000 40206098
3fff0a30: feefeffe 3ffef60c 00000000 40206710
3fff0a40: 00000000 00000000 3ffef60c 4020385d
3fff0a50: 00000000 00000000 3ffef60c 40203c3d
3fff0a60: 00000000 00000000 3ffefa5d 40203048
3fff0a70: feefeffe 00000000 3ffefa5d 402068ac
3fff0a80: feefeffe feefeffe 3ffefa70 4010070c
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d v0c897c37 ~ld`
thanks in advantage.
Davide
I have a similar exception using the example MQTTClient right after connecting to WiFi. It runs on a NodeMCU v3.
Panic C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\abi.cpp:92 __throw_bad_function_call
ctx: cont
sp: 3fff09f0 end: 3fff0c10 offset: 01b0
>>>stack>>>
3fff0ba0: 3ffefb04 0000014d 0000014d 4010020c
3fff0bb0: 3fffdad0 00000000 3fff0be0 4020664c
3fff0bc0: 00000000 00000000 00000000 402038f1
3fff0bd0: 3fffdad0 00000000 3ffef790 40203cd1
3fff0be0: 00000000 00000000 3ffefbe1 402030e8
3fff0bf0: feefeffe 00000000 3ffefbe1 402067e8
3fff0c00: feefeffe feefeffe 3ffefbf0 40100710
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
Exception translates to:
Decoding 7 results
0x4010020c: _umm_free at C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266\umm_malloc/umm_malloc.c line 1291
0x4020664c: ClientContext::read(char*, unsigned int) at C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 92
: (inlined by) WiFiClient::read(unsigned char*, unsigned int) at C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src/WiFiClient.cpp line 232
0x402038f1: GxGDEW042T2::_wakeUp() at C:\Users\Korno\Documents\Arduino\libraries\GxEPD-master/GxIO/GxIO.cpp line 37
0x40203cd1: GxGDEW042T2::drawBitmap(unsigned char const*, unsigned int, short) at C:\Users\Korno\Documents\Arduino\libraries\GxEPD-master/GxIO/GxIO.cpp line 37
0x402030e8: GxIO_SPI::transferTransaction(unsigned char) at C:\Users\Korno\Documents\Arduino\libraries\GxEPD-master/GxIO/GxIO.cpp line 37
0x402067e8: ClientContext::read(char*, unsigned int) at C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\libraries\ESP8266WiFi\src/WiFiClientSecure.cpp line 761
0x40100710: cont_norm at C:\Users\Korno\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.0\cores\esp8266/cont.S line 109
@tuanpmt could you have a look on this?
//edit Rolling back to v1.4 solved the problem for me.
Hi! I'm having the same problem: Not using mqtts though
Panic C:\Users\proje\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.4.1\cores\esp8266\abi.cpp:92 __throw_bad_function_call
ctx: cont
sp: 3fff12b0 end: 3fff14d0 offset: 01b0
>>>stack>>>
3fff1460: 00000000 00000000 00000000 00000000
3fff1470: 40252572 3fff0499 00000000 40213240
3fff1480: 4025373f feefeffe feefeffe 4020d46d
3fff1490: 3fff1ae4 4020a0c0 3ffeffd0 4021157d
3fff14a0: feefeffe 00000000 3fff0499 402084e4
3fff14b0: 3fffdad0 00000000 3fff0499 402133cc
3fff14c0: feefeffe feefeffe 3fff04b0 40100710
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset
@skornehl , this is on v1.0.4
Any suggestions?
Thanks
hmm no answer ?
Have the same problem... any news?
I have the same issue on a ESP12 devboard; rolling back to 1.0.4 fixes the crash for me.
Hi, i fix it with this: mqtt.onDisconnect( { Serial.printf("MQTT: Disconnected\r\n"); });
after connect in setup function. But i found another bug. You can't send mqtt message with zero data