-
Notifications
You must be signed in to change notification settings - Fork 13.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTTPClient causes exception(28) in 2.4.0-rc2 #4060
Comments
Please retest with latest git. |
With the latest git the beaviour is another, when the HTTP Error -1 occurs.
-> WiFi Connection fails, so I do a ESP.restart();
|
It seems that the condition In my code I do a WiFi re-connect, with a wait time of 15 seconds to connect:
The only way to reconnect to the WiFi network is restarting the device. |
I have created a new small sample sketch: #include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
char ssid[] = "none";
char key[] = "thisissecret";
unsigned long lastMillis = 0;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
Serial.begin(115200);
if (doWifiConnect()) {
Serial.println("WiFi connection successful!");
} else ESP.restart();
}
void loop() {
if (millis() - lastMillis > 5000) {
lastMillis = millis();
doHttpCall();
}
}
void doHttpCall() {
Serial.println("Current WiFi.status() = "+String(WiFi.status()));
if (WiFi.status() == WL_CONNECTED) {
HTTPClient http;
http.setTimeout(1500);
http.begin("http://192.168.1.1/index.htm");
int httpCode = http.GET();
if (httpCode > 0) {
Serial.println("HTTP success");
String payload = http.getString();
}
if (httpCode != 200) {
Serial.println("HTTP fail " + String(httpCode));
}
http.end();
} else {
//WiFi.reconnect();
//doWifiConnect();
}
}
bool doWifiConnect() {
Serial.println("Connecting WLAN...");
//WiFi.disconnect(true);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, key);
int waitCounter = 0;
digitalWrite(LED_BUILTIN, LOW);
while (WiFi.status() != WL_CONNECTED) {
waitCounter++;
if (waitCounter == 20) {
digitalWrite(LED_BUILTIN, HIGH);
return false;
}
delay(500);
}
digitalWrite(LED_BUILTIN, HIGH);
Serial.println("Wifi Connected");
return true;
} The Debug Output is:
--- Now here I've disconnected my access point ---
The decoded stack is:
|
@jp112sdl Please retest with the referenced PR. |
@devyte I will let it run a few hours... sometimes the exception also occured after WPA Re-Keying interval. |
related to esp8266#4101 esp8266#4078 esp8266#4060 esp8266#4028 and maybe others
related to esp8266#4101 esp8266#4078 esp8266#4060 esp8266#4028 and maybe others
Basic Infos
Hardware
Hardware: ESP-12
Core Version: 2.4.0-rc2
Description
HTTPClient causes exception(28)
Settings in IDE
Module: Generic ESP8285 Module
Flash Size: 1MB
Flash Mode: DOUT
Upload Using: OTA
Reset Method: ck
Sketch
Debug Messages
In my code I'm calling a http.Get() every 30 seconds.
That works for a few hours.
Then I get a few times a HTTP Return Code (-1) (
HTTPC_ERROR_CONNECTION_REFUSED
) and after that it seems that the WiFi connection is lost.A new attempt to establish the Wifi connection fails.
With the latest stable Version 2.3.0 everything works fine.
The text was updated successfully, but these errors were encountered: