Post topics, source code that relate to the Arduino Platform

User avatar
By NardJ
#28985 I notice my esp8266 suddenly crashing on boot if I increase the number of pages served (using ESP8266WebServer.on). Is there a max of pages which can be served? Or could this be a memory problem (334.212 program memory used / 69.240 dynamic memory used). Some of the code:
Code: Select all#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>

ESP8266WebServer server(80);
const char gui[] PROGMEM = ... (large char string)
const char vicii[] PROGMEM =  ...(larger char string)

void KeyDown(){
}
void VICIIUpdates(){
}
...
void setup(){
  ...
  server.on ( "/",[]() {
                    server.send ( 200, "text/html", gui);
                   });
  server.on ( "/VICII.js",[]() {
                    server.send ( 200, "text/plain", vicii);
                   });             
  server.on ( "/VICIIRefresh", VICIIRefresh);

  //on turning one of the following on the esp crashes on boot
  //  server.on ( "/VICIIUpdates", VICIIUpdates); 
  //  server.on ( "/KeyDown", KeyDown);

  server.onNotFound(handleNotFound);
  ...
}
User avatar
By martinayotte
#28990 In your code, we see that you are using PROGMEM, but you are sending them using server.send() instead of server.send_P(). This is a potential problem.
But for the fact that it crash at boot time, it maybe another issue. We need more clues.
For page count, I have an sketch that has more than 10 server.on(), so I don't think the problem is there.
User avatar
By NardJ
#29029 Well, I found the cause:
Code: Select allWiFi.begin(ssid, password);

If I comment out this line all is fine.... except I don't have wifi off course.

The HelloWebserver example sketch of the ESP8266WebServer library runs fine every time! Maybe because it lacks the large progmem declarations.

Attached the full sketch.

(PS, on using the command 'server.send_P()' the error 'ESP8266WebServer has no member named send_P' appears.)
You do not have the required permissions to view the files attached to this post.
User avatar
By martinayotte
#29030
NardJ wrote:(PS, on using the command 'server.send_P()' the error 'ESP8266WebServer has no member named send_P' appears.)


This is because you don't have the latest sources from 'staging', the commit has been done on July 24th, https://github.com/esp8266/Arduino/comm ... 03280c5c76