tzapu / WiFiManager

ESP8266 WiFi Connection manager with web captive portal
http://tzapu.com/esp8266-wifi-connection-manager-library-arduino-ide/
MIT License
6.52k stars 1.96k forks source link

Server returns http 400 when connected to SSID with password #819

Open jbrepogmailcom opened 5 years ago

jbrepogmailcom commented 5 years ago

Hello, I have noticed following strange behavior.

I have multiple SSIDs provided by my home ZYXEL router, some with password, some without it. I use WiFiManager.h to autoconnect to SSID. When it does not detect connection, it launches captive portal, where I can select some of my SSID, enter password and ESP then connects to that SSID.

Then I use OTA from web server, with ESP8266HTTPClient.h and ESP8266httpUpdate.h. I noticed that when I am connected to SSID with password, I can not connect to OTA server and it returns http code 400. When I reconnect to other SSID without password, then OTA server returns http code 200 and server the update file.

Jan

tablatronix commented 5 years ago

SO when your esp is connected to an anoymous ap it works, and when its connected to a secure ap it doesn't ?

and have you tried this without wm , because it doesn't sound like anything to do with wm. Sounds like a subnet or ip routing problem

jbrepogmailcom commented 5 years ago

Yes exactly. It could be a problem of internal ZYXEL routing, because SSIDs have different MAC addresses.

However, when I tried HttpClient example from Arduino library that does not use WM, it connects to server correctly through both secure and insecure AP. My example with WM only connects to web server when connected to insecure AP (without password). I can send you problematic sketch, but not over this issue management, it would make messages hard to read.

tablatronix commented 5 years ago

Are you setting mode(WIFI_STA) explicitly, and making sure it is not falling back to STA_AP ?

jbrepogmailcom commented 5 years ago

In Arduino example yes and it works. In my sketch that uses WM there is no such setting, I connect with following code. It works well and does connect to AP (but not to http server, only with empty password). By the way, I had troubles with secure SSID earlier, I discovered I was using beta version of JSON library. I could not connect to secure SSID. When I downgraded JSON library, then secure SSID connection started to work.

Serial.println("Setting WiFi connection..."); delay(100); pinMode(LED_ESP, OUTPUT); ticker.attach(0.6, tick); WiFiManager wifiManager; wifiManager.setAPCallback(configModeCallback); if (!wifiManager.autoConnect(D_Name)) { Serial.println("failed to connect and hit timeout"); ESP.reset(); delay(1000); } Serial.println("connected...yeey :)");

tablatronix commented 5 years ago

that is the only thing I can think of, that the esp is being left in the default sta ap mode and you are not changing it in your code. This could cause issues with connecting to some aps, set mode explicitly in your code to what you need it to do

jbrepogmailcom commented 5 years ago

Does "wifiManager.autoConnect()" set STA mode itself? Or how do I do it? Googling did not help much...

tablatronix commented 5 years ago

WiFi.mode(WIFI_STA);

jbrepogmailcom commented 5 years ago

I have added it after autoConnect(): WiFi.mode(WIFI_STA); Serial.println("connected...yeey :)");

but the problem remains, http GET only works with SSID without password. With password, server returns 400 (error -11).

Interesting is that GET and telegram check connection DOES NOT work, while BLYNK sending parameters DOES work even with secure SSID...

tablatronix commented 5 years ago

If you want to provide all the information in the issue form I can look into it.

You can try the development branch and see if it already been fixed