Comments (3)
The sketch is wrong. Handle handleClient outside the timer loop. That's the way to use the WebServer library.
from autoconnect.
The sketch is wrong. Handle handleClient outside the timer loop. That's the way to use the WebServer library.
In all of your examples you put handleClient
or handleRequest
inside void loop() {}
.
If you know how to fix this sketch please help me. I wouldn't have bothered you, but I couldn't find any tutorial or guide.
from autoconnect.
ESP32 is multicore, but AutoConnect hosts the WebServer instances in the same core, not multitasking. AutoConnect::handleClient internally calls WebServer::handleClient, but it resides in the same thread. Therefore it is the same as ESP8266WebServer::handleClient even if running on ESP32. See the documentation.
In all of your examples you put
handleClient
orhandleRequest
insidevoid loop() {}
.
If your sketch intends to respond to another HTTP request as a web server at the same time issuing a GET request every 10 seconds, delay(10000);
stalls WebServer process because it runs in the same thread. So WebServer cannot respond to new HTTP requests. It will cause a timeout error on the client (usually a web browser). The outside of the timer loop means that handleClient must be performed under the loop()
immediately avoid delay(10000);
. Because it is not multitasking. I encourage you to first read all the necessary documentation for ESP32, ESP8266. AutoConnect assumes an understanding of the basic usage of the ESP8266WebServer library.
I don't know your sketch intention, but the sketch below will be helpful. It excludes AutoConnect from your sketch and made it just using the WebServer library. This is not work properly.
So, it is not a problem with AutoConnect. Make sure that you first the confirmation on the WebServer library only and post it.
#include <WiFi.h>
#include <WebServer.h>
#include <HTTPClient.h>
WebServer Server;
void rootPage() {
char content[] = "Hello, world !";
Server.send(200, "text/plain", content);
}
void setup () {
delay(1000);
Serial.begin(115200);
Serial.println();
Server.on("/", rootPage);
WiFi.mode(WIFI_STA);
WiFi.begin("YOUR_SSID", "YOUR_PASSWORD");
while (WiFi.status() != WL_CONNECTED) {
delay(300);
}
Serial.println("WiFi Connected: " + WiFi.localIP().toString());
Server.begin();
}
void loop() {
HTTPClient http;
http.begin("http://jsonplaceholder.typicode.com/comments?id=10"); //Specify the URL
int httpCode = http.GET();
if (httpCode > 0) {
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
} else {
Serial.println("Error on HTTP request");
}
http.end();
Server.handleClient();
delay(10000);
}
from autoconnect.
Related Issues (20)
- ESP32 problem HOT 8
- Mqtt Example HOT 2
- Using "AutoConnectCore.h" header and running into errors HOT 2
- AutoConnect to offer captive portal for 5min even if ESP32 is WiFi-Connected HOT 1
- AutoConnect on WiFi connection error shows too many redirects. HOT 2
- AutoConnectCore Not Working HOT 1
- Failing to store network HOT 2
- AutoConnect not longer runningh on ESP8266 HOT 2
- Use Autoconnect library with ESP now HOT 1
- Issue after updating libraries in my PIO project: enableCors() HOT 2
- Strange Issue
- WiFiClientSecure is not working with AutoConnect HOT 1
- how to use esp8266 with WiFiClientSecure
- AutoConnectPageImpl.hpp:1001:20: error: there are no arguments to 'spi_flash_get_chip_size' that depend on a template parameter, so a declaration of 'spi_flash_get_chip_size' must be available [-fpermissive] HOT 2
- Save data from Custom Page to flash HOT 2
- esp32: frozen loop() and kicked out of the WiFi connection at Configure new AP
- WPA2 Enterprise support
- Captive portal cause watchdog triggering
- Possibility to change pass for SoftAP from webui.
- Fresh Install and even the simplest of code will not compile HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from autoconnect.