mirror of
https://github.com/tzapu/WiFiManager.git
synced 2026-04-27 00:55:52 +03:00
[GH-ISSUE #698] WifiClientSecure, PubSubClient and WifiManager dont work together #584
Labels
No labels
📶 WiFi
🕸️ HTTP
Branch
DEV Help Wanted
Discussion
Documentation
ESP32
Example
Good First Issue
Hotfix
In Progress
Incomplete
Needs Feeback
Priority
QA
Question
Task
Upstream/Dependancy
bug
duplicate
enhancement
invalid
pull-request
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/WiFiManager#584
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @arrowcircle on GitHub (Aug 10, 2018).
Original GitHub issue: https://github.com/tzapu/WiFiManager/issues/698
Basic Infos
WifiClientSecure, PubSubClient and WifiManager dont play nice together.
Hardware
NodeMCU dev board.
Description
When I use WifiManager, I cant connect to Secure MQTT broker. When I remove WiFiManager and connect to wifi manually - it works great.
Settings in IDE
[env:native]
platform = native
test_filter = native
debug_tool = native
lib_ignore =
Adafruit BMP280 Library
Adafruit Unified Sensor
PubSubClient
ArduinoJson
WifiManager
[env:esp01]
platform = espressif8266
board = esp01
framework = arduino
upload_speed = 921600
monitor_speed = 115200
test_filter = esp01
build_flags = -DDEBUG_ESP_WIFI
lib_deps =
Wire
I2C
SPI
Adafruit BMP280 Library@1.0.2
Adafruit Unified Sensor@1.0.2
PubSubClient@2.6
ArduinoJson@5.13.2
WifiManager@0.14
Sketch
Serial Output
@uched41 commented on GitHub (Aug 15, 2018):
I had this problem a few days ago. Declaring the
wifiManagerin global scope, just before the WiFiClient works for me, no real reason here.I also noticed that if I use:
wifiManager.setSTAStaticIPConfigthe mqtt does not work. These are random solutions but might we worth a try.@tablatronix commented on GitHub (Aug 15, 2018):
hmm did you test this in development branch?
@bkrajendra commented on GitHub (Sep 3, 2018):
Yes @uched41 I also observed similar issue with MQTT.
With me actually MQTT doe not connect when we do first time WiFi configuration. But we need to reset ESP to connect MQTT. After reset MQTT works properly. This might be related to how WiFi is connected. and how MQTT is initialised or connected to brocker. Something is happening in sequence. As you need to have WiFi connection before you try mqtt.begin(), but you dont have it while WiFi config.
But I tried putting mqtt.begin in after wifi ip is printed but does not help me.
I used Dev branch.
@tablatronix commented on GitHub (Sep 3, 2018):
There seems to be some kind of esp bug, where it wont reconnect properly if it thinks is already is.
@tablatronix commented on GitHub (Sep 3, 2018):
are you using set static config?
@bkrajendra commented on GitHub (Sep 3, 2018):
Im using static IP for STA.
@tablatronix commented on GitHub (Sep 3, 2018):
#720
@shahabmusic commented on GitHub (Jan 12, 2019):
I am having the same problem. When I use ESP8266WebServer, esp8266 crash when connecting to secure mqtt. If I don'tdeclare websaver and don't use webserver, esp8266 does not crash and secure mqtt connects with no issue.
here is the error
Attempting MQTT connection...Fatal exception 28(LoadProhibitedCause):
epc1=0x402159d4, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Exception (28):
epc1=0x402159d4 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
here is the stack:
Decoding stack results
0x40228cf4: hash_dn at src/x509/x509_minimal.c line 363
0x40229487: br_x509_minimal_run at src/x509/x509_minimal.c line 1208
0x40229d8a: xm_append at src/x509/x509_minimal.c line 285
0x40223d70: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 1863
0x40221d98: jump_handshake at src/ssl/ssl_engine.c line 1081
0x4022227d: br_ssl_engine_recvrec_ack at src/ssl/ssl_engine.c line 1206
0x40205f21: BearSSL::WiFiClientSecure::run_until(unsigned int, bool) at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 497
0x402228ec: br_ssl_hs_client_run at src/ssl/ssl_hs_client.c line 958
0x40222894: br_ssl_hs_client_init_main at /home/earle/Arduino/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/sys/pgmspace.h line 67
0x402223a2: br_ssl_engine_hs_reset at src/ssl/ssl_engine.c line 1305
0x40206130: BearSSL::WiFiClientSecure::wait_for_handshake() at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 521
0x402062c3: BearSSL::WiFiClientSecure::connectSSL(char const*) at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 930
0x4020888c: esp_yield() at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\core_esp8266_main.cpp line 91
0x402014eb: delay at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\core_esp8266_wiring.c line 51
0x40204f2a: WiFiClient::connect(IPAddress const&, unsigned short) at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src/include/ClientContext.h line 136
0x40100114: millis at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\core_esp8266_wiring.c line 183
0x40206386: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 218
0x40208fdc: PubSubClient::connected() at C:\Users\light\OneDrive\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.cpp line 606
0x4020688b: PubSubClient::connect(char const*, char const*, char const*, char const*, unsigned char, unsigned char, char const*, unsigned char) at C:\Users\light\OneDrive\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.cpp line 129
0x4010038c: umm_free at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\umm_malloc\umm_malloc.c line 1300
0x40206a74: PubSubClient::connect(char const*) at C:\Users\light\OneDrive\Documents\Arduino\libraries\PubSubClient\src\PubSubClient.cpp line 106
0x40208198: String::~String() at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\WString.cpp line 125
0x40202c08: reconnect() at C:\Users\light\OneDrive\Documents\Arduino\BearSSL_Validation_test_mqtt/BearSSL_Validation_test_mqtt.ino line 271
0x40206e0d: std::function ::operator= &>(std::function &) at c:\users\light\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 2331
0x4020555f: BearSSL::WiFiClientSecure::connected() at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\libraries\ESP8266WiFi\src\WiFiClientSecureBearSSL.cpp line 246
0x40202cf4: loop() at C:\Users\light\OneDrive\Documents\Arduino\BearSSL_Validation_test_mqtt/BearSSL_Validation_test_mqtt.ino line 292
0x40208938: loop_wrapper() at C:\Users\light\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0-beta2\cores\esp8266\core_esp8266_main.cpp line 125
@shahabmusic commented on GitHub (Feb 1, 2019):
I am having the same issue. when I use client.setInsecure(), it connects with no problems. however it crashes when I use client.setTrustAnchors(&cert).
I used to solve this issue by not declaring webserver. but now it does not work even if I don't declare webserver
@dontsovcmc commented on GitHub (Nov 6, 2019):
Maybe it's out of memory? TLS connection needs about 25kb. I have a crash in TLS new operator after ConfigPortal: https://github.com/dontsovcmc/waterius/issues/82 but I don't have a loop.
@chaseTfreeman commented on GitHub (Jun 11, 2020):
Hello I'm having similar issues and hoping someone has a working example. My issue is that ".subscribe" is not calling the callback. I am seeing a "1" returned when I print the result of the subscribe.
I am using pubsubclient, wificlientsecure, and wifimanager. I'm using AWS as my MQTT server. I have no problem publishing but cannot subscribe successfully.
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <WiFiManager.h> //https://github.com/tzapu/WiFiManager
}
@adeltc commented on GitHub (Jan 20, 2021):
Any progress on this issue. I'm still seeing with the last versions of the wifimanager and PubSubClient. The symptoms I'm seeing the WifiManager Auto connect that stop broadcasting SSID in AP mode. As soon as I remove the TLS code (replace "WiFiClientSecure" with "WiFiClient" ), It works perfectly. When I put back "WiFiClientSecure", the AP mode stop working correctly, SSID is not visible anymore.
In the beginning, I though it was an out of memory issue then I moved the code that instantiates "WiFiClientSecure" after the Wifi Manager AutoConnect... so "WiFiClientSecure" is not instantiated before the WifiManager Autoconnect complete. Even then I still see the same issue.
Long story short, as soon as the code of "WiFiClientSecure" compiles, the WifiManager Autoconnect stops working correctly... even if we don't instantiate the variables.
@tablatronix commented on GitHub (Jan 20, 2021):
Shrug no one has posted logs from dev
@chaseTfreeman commented on GitHub (Jan 20, 2021):
@adeltc - My configuration works, except for the
.subscribefrom the pub/sub client. Perhaps you can share your code?@adeltc commented on GitHub (Jan 21, 2021):
I got my problem solved by Selecting "Basic SSL ciphers(lower ROM use)" in th Arduino Menu "Tools"-->"SSL Support".
If I select back "All ciphers" then my problem comes back: the SSID of of the Autoconnect in AP doesn't show up. Can't see neither with my phone or my laptop. So it's impossible to connect to the esp
@tablatronix commented on GitHub (Jan 21, 2021):
Is there any port overlap, that is a known issue that was just fixed in esp lib
@adeltc commented on GitHub (Jan 22, 2021):
I used only one TCP connection for the WifiManager AutoConnect... by default, it's using port 80 to provide the configuration gui.
@tomcircuit commented on GitHub (Dec 28, 2021):
I'm observing a similar conflict (I think) between WifiManager and WifiClientSecure on an ESP8266. I'm using UniversalTelegramBot library which, in turn, requires WfiClientSecure. I have no issue compiling, and the WifiManager works as expected - first boot starting an AP, subsequent boot leaving the ESP8266 connected to my test WLAN. My loop() seems to be executing correctly: I can see reports via serial console every few seconds that indicate the NTP service is working, telemetry data is being logged, but secure com with Telegram server isn't working. I've tried compiling with the "Basic SSL Ciphers(Lower ROM use)" option, also, with no success. The previous version of my sketch doesn't use WifiManager (hardcoded SSID, PW) and has been working for months without any issues.
I really, really, want to use WifiManager to allow WLAN configuration, as well as allowing user entry of some parameters (Telegram bot ID, Telegram user chat ID) to avoid unique edit/compile/upload for these telemetry sensors. Hoping there's a solution for this, somewhere!
@MLDMoritz commented on GitHub (Apr 26, 2022):
This problem is still persisting, any tips?
@tablatronix commented on GitHub (Apr 26, 2022):
Hmm I have noticed a problem with closing down either the web server or the dns server , these could be conflicting. I use pubsub client and wm and have not had issues let me try again. Can you provide anymore info, have you tried running wm in a non global scope?
@ddp75 commented on GitHub (Jan 9, 2023):
Try this :
#include <WiFiManager.h>
WiFiManager wm; // This line just after #include <WiFiManager.h>
//...
#include <PubSubClient.h>
@azcoov commented on GitHub (Jul 26, 2024):
I just ran into this same issue on a D32 Pro board. Based on the @bkrajendra comment on Sep 3, 2018 and @tablatronix reply, I came up with hack that works well, though I would never deploy this beyond my development board...
I'm using PubSubClient to communicate with AWS IoT Core. It works fine with WiFiClientSecure. Once I introduced WiFiManager into the mix, I would get DNS errors trying to resolve the AWS IOT host. Something like
DNS Failed for xxxxx.iot.us-east-1.amazonaws.com.I started checking the host name in several places in the code:
The host name does not resolve until after
WiFi.begin(ssid, pw);and theWiFi.status()isWL_CONNECTED, which makes sense. And that is great if all you are using is WiFiClientSecure.To work around the issue, once the WiFiManager setup process is complete, I save the ssid
wm.getWiFiSSID() or WiFi.SSID()and pwwm.getWiFiPass() or WiFi.psk()locally via SPIFFS and then I boot with anESP.restart();.On setup, I look to see if I have saved credentials. If I do, then I bypass WiFiManager and use WiFiClientSecure with the saved credentials, my host name resolves, and I'm good to go. If the WiFi fails to connect this way (most likely due to a WiFi password change, I clear out the saved credentials an boot again, which will launch the WiFiManager again.
I also added a function and a button that wipes the WiFiManager settings so that I can get back to the WiFiManager interface ass needed, which was my goal as I bounce around different WiFi networks testing my sensor.
Hopefully this workaround helps someone, but consider it a temporary fast switch and not something to deploy.
And thank you for the library. The WiFiManager experience, especially with the custom
WiFiManagerParameteris awesome. Much better than some production products I use with clunky access point interfaces.