Core Installation version: 1.0.4
IDE name: Arduino 1.8.9
Flash Frequency: 80MHz
PSRAM enabled: ?no? ?yes?
Upload Speed: 921600
Computer OS: Windows 7/64 pro
Browser: Firefox 77.0.1
Adafruit Feather ESP32
setup() code for wifiserver and webserver works fine on ESP8266 and appearently also is fine for ESP32, but then it crashes when creating the website.
What is wrong with the website code?
What is it not esp8266-compatible but crashes?
#include <WiFi.h>
#include <WebServer.h>
IPAddress this_ip(192, 168, 2, 201); //
IPAddress gateway(192, 168, 2, 1); // <<< LAN Gateway IP
IPAddress subnet(255, 255, 255, 0); // <<< LAN Subnet Mask
WiFiServer wifiserver(8080);
WebServer webserver(8081);
const char* ssid="ssss"; // WIFI network name
const char* password="pppp"; // WIFI network password
//...
void setup() {
Serial.begin(115200);
delay(1000);
//----------------------------------------
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.println("Connecting to WiFi: ");
Serial.println( WiFi.gatewayIP().toString() );
WiFi.mode(WIFI_STA);
WiFi.config(this_ip, gateway, subnet, gateway, gateway); // dns = gateway
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi connected: ");
Serial.println(WiFi.gatewayIP());
//----------------------------------------
wifiserver.begin();
Serial.println("WiFi Server started");
//----------------------------------------
webserver.on("/", handleRoot) ;
webserver.on("/client/client0/", handleClients);
delay(10);
webserver.begin();
Serial.println("ESP webserver started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://"); Serial.print(WiFi.localIP());
Serial.print(":"); Serial.print(8080);
Serial.println("/");
Serial.println((String)"myweb.sytes.net" + ":" + (String)(8080) + "/");
Serial.println("setup done ");
}
void loop() {
Serial.println("\nDEBUG:\n new loop");
static double ftmp;
static unsigned long tsec = millis(), tms = millis();
Serial.println("\nDEBUG:\n handleWebsite()");
handleWebsite(); // <<<<<<<<<<<<<<<<<<<<<<<<<< CRASH !!
Serial.println("\nDEBUG:\n webserver.handleClient()"); // <<<<<<<<<< not executed any more
webserver.handleClient();
//---------------------------------------
// Read local data
ftmp = -99;
//ftmp = bmp_x77.readTemperature();
//
}
void handleWebsite() {
WiFiClient client = wifiserver.available();
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
String script = "";
script += ("HTTP/1.1 200 OK \n");
script += ("Content-Type: text/html \n");
script += ("\n");
script += ("<!DOCTYPE html> \n");
script += ("<html> \n");
// head + title
script += ("<head> \n");
// autom. Aktualisierung alle 20 sec.
script += "<meta http-equiv=\"refresh\" content=\"20; URL=";
script += (String)"myweb.sytes.net" + ":" + (String)(8080) + "\"> \n" ;
// utf-8 f眉r "掳" Zeichen
script += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n" ;
script += ("<title>");
script += "myweb.sytes.net";
script += ("</title> \n");
script += ("</head> \n");
// body + caption
script += ("<body> \n");
script += ("<h1> <p> ");
script += (String)"test" + " " + WiFi.localIP().toString() + " " + (String)ssid + " <br>" ;
script += "</p> </h1> \n";
script += "</body> \n";
script += "</html> \n";
script += ("<br> \n");
script += ("<br> \n");
client.print(script);
script = "";
delay(1);
}
void handleRoot() {;}
void handleClients() {;}
Connecting to WiFi:
0.0.0.0
.
WiFi connected: 192.168.2.1
WiFi Server started
ESP webserver started
Use this URL to connect: http://192.168.2.201:8080/
myweb.sytes.net:8080/
setup done
DEBUG:
new loop
DEBUG:
handleWebsite()
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d6ab4 PS : 0x00060630 A0 : 0x800d6b88 A1 : 0x3ffb1e10
A2 : 0x00000000 A3 : 0x3ffb1e5f A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00060220 A7 : 0x00000000 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00000080 A12 : 0x00000050 A13 : 0x00000001
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xfffffff9
Backtrace: 0x400d6ab4:0x3ffb1e10 0x400d6b85:0x3ffb1e30 0x4014ae16:0x3ffb1e50 0x400dbfb1:0x3ffb1e80 0x400dc049:0x3ffb1ea0 0x400d4491:0x3ffb1ec0 0x400d4827:0x3ffb1f80 0x400deac5:0x3ffb1fb0 0x400896d9:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
Client may be null in loop is the only thing I can see. You will need to decide the backtrace to know for certain where the null dereference is happening.
tbh, I do not understand.
The code is working for esp8266 since many years and is also Arduino Wifi shield compatible, so what shall I do exactly?
which would be the correct esp32 code for building the website?
repeating how it works on 8266 will not help you much. decoding the issue with the ExceptionDecoder might actually help. Link and instructions were in the issue template that you edited. Also can be found in the readme. And since you so much "works on 8266 for ages" 8266 uses the same exception decoder.
I don't know how to do that decoding with the ExceptionDecoder.
OTOH, for esp8266 there is no issue and never was, there all the code runs like a charm, so I never needed the ExceptionDecoder so far.
then maybe good time to learn to use it if you want help.
I do not understand that, that is way too complicated https://github.com/me-no-dev/EspExceptionDecoder - any help highly appreciated!
ok, let me try to say it more clear.
We can not give you any help unless you decode your backtraces. There are tutorials, youtube videos and more on how to install and use the exception decoder. Also in your code you did not show handleRoot().
yes, a c+p error.
I meanwhile updated the code which now compiles fine.
PS,
after installing the decoder I get no elf trace or whatever
you need to paste the backtrace into the window... and the sketch to be compiled and running. Did you look at any video?
I don't get a window, just a file to select (which is not existent).
I also don't understand English well (I am using Google translator).
Can please test this thing anyone who is experienced?
You open the sketch in Arduino IDE, you compile and upload the sketch to the board, then open the serial monitor so you can receive the error. Now open the exception decoder, it will not ask you for file, paste the error in the top half and you will get the result.
I did all that, I created a new empty file, then I opened that file, then I pasted the code, but I don't get a result.
In your first post, there is a debug part. Guru Meditation Error....
The end is rebooting and date. Before that ther is a line with Backtrace: .....
That line have to be copied to the expectiondecoder including the "Backtrace:" , while your board connected and running the code that cause the error.
Btw, probably it is the HTTPClient related issue that cause a lot of problem in 1.0.3 and 1.0.4 core.
Read #4039 and #3347 .
yes, I copied the line Backtrace, but got no result.
I also tried 1.0.2, same crash.
What is the solution to the Guru crash problem?
What is the solution to the Guru crash problem?
Find and fix issue.
@dsyleixa you must compile your sketch in the same ardunio ide as you are using the backtrace decoder. Copy/paste the trace from the serial monitor in the ide into the trace window and it should produce a meaningful decode output. The decoder has a required dependency on the binary produced by the ide in order to decode the trace.
yes, I did that, but no result.
@dsyleixa you must compile your sketch in the same ardunio ide as you are using the backtrace decoder. Copy/paste the trace from the serial monitor in the ide into the trace window and it should produce a meaningful decode output. The decoder has a required dependency on the binary produced by the ide in order to decode the trace.
Can please test my code anyone who is experienced?
Then you probably not installed correctly the decoder. It gives me result if i put your backtrace to my decoder but thats not gives the good result because i havent got your code, and i have different operating system, file system etc...
Then I don't think we can help narrow down the cause for the failure if the decoding is not happening. From a very quick read of the code it doesn't look like there is any error checking being done in handleWebsite() which would include checking that wifiserver.available() returned a valid client object (if none are available it can return nullptr).
Also assigning script at the end of that method is not necessary. The variable will go out of scope and be cleaned up automatically upon exit from the function. You could also improve the function a bit by directly calling client.print() directly
You may dislike my answer, but its only correct.
There is tens of tens situations that can cause Guru crash. My bet is you are trying to access not initialized variable.
chegewara, if you cannot provide a reasonable fix, please troll somewhere else.
@dsyleixa he isn't trolling. He is staying fact. There are many ways to encounter such crashes and often times they are due to simple mistakes
I do not understand what to do now, I am just an Arduino hobby-user.
Can you please try my code and see if you can find the reason?
Or provide a code like mine which is working?
Then I don't think we can help narrow down the cause for the failure if the decoding is not happening. From a very quick read of the code it doesn't look like there is any error checking being done in handleWebsite() which would include checking that wifiserver.available() returned a valid client object (if none are available it can return nullptr).
Also assigning script at the end of that method is not necessary. The variable will go out of scope and be cleaned up automatically upon exit from the function. You could also improve the function a bit by directly calling client.print() directly
I do not understand what to do now, I am just an Arduino hobby-user.
Can you please try my code and see if you can find the reason?
No, because you will never learn to use backtrace decoder and will get back here with every single crash.
chegewara, if you cannot provide a reasonable fix, please troll somewhere else.
@me-no-dev Please close this issue
@me-no-dev Please block chegewara.
The code is esp8266 and Arduino Wifi shield compatible and I never had crashes there.
@dsyleixa esp32 is not the same as esp8266 and it never will be.
You can try adjusting your handleWebsite() to look like this:
void handleWebsite() {
WiFiClient client = wifiserver.available();
if (!client) {
return;
}
String request = client.readStringUntil('\r');
This checks that the client object that was returned from the server listener is valid (ie: connected to something) and if not it gets out of the method before trying to use it.
As for the other suggestion you can do something like this directly and save yourself a lot of memory on the stack:
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // blank newline after header data
We can't test your code because github has not private messaging. If you can send your code an other way to me, i give it a test, but today i only have about 30 min then i go.
@usane1:
the code is completely what I posted in the top, nothing else yet
update:
I applied your changes, now no crashes but also still no website generated:
Here is what i got from decoding:
PC: 0x400d18dc: WiFiClientRxBuffer::read(unsigned char*, unsigned int) at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src\WiFiClient.cpp line 107
EXCVADDR: 0x00000008
Decoding stack results
0x400d18dc: WiFiClientRxBuffer::read(unsigned char*, unsigned int) at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src\WiFiClient.cpp line 107
0x400d19ad: WiFiClient::read(unsigned char*, unsigned int) at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src\WiFiClient.cpp line 434
0x4014245a: WiFiClient::read() at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\libraries\WiFi\src\WiFiClient.cpp line 345
0x400d67ad: Stream::timedRead() at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\Stream.cpp line 36
0x400d6845: Stream::readStringUntil(char) at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\Stream.cpp line 287
0x400d12d1: handleWebsite() at C:\Users\Office-1\Desktop\sketch_jun15a/sketch_jun15a.ino line 79
0x400d165f: loop() at C:\Users\Office-1\Desktop\sketch_jun15a/sketch_jun15a.ino line 62
0x400d74f9: loopTask(void*) at C:\Users\Office-1\AppData\Local\Arduino15\packages\esp32\hardware\esp32\1.0.4\cores\esp32\main.cpp line 19
0x40088b7d: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143
and what does that mean now?
I applied your changes, now no crashes but also still no website generated:
well, it looks like it hasn't accepted a connection. You may need to turn up the core debug log level to see what might be going on in the underlying layers. Set your board type to the ESP32 Dev board (should be one of the first ones in the list) and you will find a core debug log level menu option, set it to DEBUG and reflash the sketch.
@usane1 has decoded the backtrace and it points to using a null client object which you have a fix for now.
what is a null client object and how to use that?
@usane1 has decoded the backtrace and it points to using a null client object which you have a fix for now.
which i pointed here:
My bet is you are trying to access not initialized variable.
chegewara, stop your superior attitude and move along!
@atanisoft:
what is a null client object and how to use that?
what is a null client object and how to use that?
The listener did not have a connected client so it defaulted to return a null value. It is always a good idea to validate the return values from APIs to ensure they did not report an error condition (which this could be taken as).
chegewara, stop your superior attitude and move along!
We are all trying to help you and continued attacks will result in no further help. Please reign it in a bit.
what is a null client object and how to use that?
The listener did not have a connected client so it defaulted to return a null value. It is always a good idea to validate the return values from APIs to ensure they did not report an error condition (which this could be taken as).
I don't understand a word, I never needed that for Arduino Wifi oder esp8266.
what is the correct code for that?
what is the correct code for that?
We are all trying to help you and continued attacks will result in no further help. Please reign it in a bit.
He is right, im not trying to help him to solve that issue. All he is is doing is wining to test his code and this is not his first issue like that:
https://github.com/espressif/arduino-esp32/issues/3444
https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue+author%3Adsyleixa+is%3Aclosed
If someone does not want to learn then does not deserve help and attention.
chegewara, troll somewhere else!
I highly appreciate help from people who want to help though.
what is the correct code for that?
I still don't understand.
All I see is my old code line
WiFiClient client = server.available();
What is the null client code there?
Chekt the line in the example code:
if(client){
....
}
That means if it doesnt run to dis loop then nothing connected to the ESP, that means nullclient.
I highly appreciate help from people who want to help though.
i doubt
https://github.com/espressif/arduino-esp32/issues/3444#issuecomment-551930831
ok, so I just have to wrap
if(client){
....
}
around?
I'll try immediately!
edit:
code runs through, no Guru error, but still no website created!
That only solve the Meditation error, but doesnt't solve why the client cannot connect to the ESP, that what is need to figure out.
Now i have to go. Hope you will have a solution.
the code runs through, no Guru errror, but also no website created!
Just a quick thought... you are connecting to port 8080 and not 8081 correct? I see you have a WebServer instance configured for 8081 and the handlers are stubbed off to not do anything which could give you the results you are seeing. But if you are connecting to 8081 I would expect it to work, perhaps you can add some Serial.println() statements in your handleWebsite() method to see where it is getting to?
yes, ports 8080 for wifiserver and 8081 for webserver work fine with esp8266:
WiFiServer wifiserver(8080);
WebServer webserver(8081);
I will add some prints.
runs through, no client connection:
Connecting to WiFi:
0.0.0.0
.
WiFi connected: 192.168.2.1
WiFi Server started
ESP webserver started
Use this URL to connect: http://192.168.2.201:8080/
myweb.sytes.net:8080/
setup done
DEBUG:
new loop
DEBUG:
handleWebsite()
DEBUG:
!client => return
DEBUG:
webserver.handleClient()
DEBUG:
ftmp
-99.00
DEBUG:
new loop
DEBUG:
handleWebsite()
DEBUG:
!client => return
DEBUG:
webserver.handleClient()
DEBUG:
ftmp
-99.00
DEBUG:
new loop
DEBUG:
handleWebsite()
DEBUG:
!client => return
#include <WiFi.h>
#include <WebServer.h>
IPAddress this_ip(192, 168, 2, 201); //
IPAddress gateway(192, 168, 2, 1); // <<< LAN Gateway IP
IPAddress subnet(255, 255, 255, 0); // <<< LAN Subnet Mask
WiFiServer wifiserver(8080);
WebServer webserver(8081);
const char* ssid="WLAN"; // WIFI network name
const char* password="18658"; // WIFI network password
//...
void setup() {
//----------------------------------------
Serial.begin(115200);
delay(1000);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.println("Connecting to WiFi: ");
Serial.println( WiFi.gatewayIP().toString() );
WiFi.mode(WIFI_STA);
WiFi.config(this_ip, gateway, subnet, gateway, gateway); // dns = gateway
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("WiFi connected: ");
Serial.println(WiFi.gatewayIP());
//----------------------------------------
wifiserver.begin();
Serial.println("WiFi Server started");
//----------------------------------------
webserver.on("/", handleRoot) ;
webserver.on("/client/client0/", handleClients);
delay(10);
webserver.begin();
Serial.println("ESP webserver started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://"); Serial.print(WiFi.localIP());
Serial.print(":"); Serial.print(8080);
Serial.println("/");
Serial.println((String)"myweb.sytes.net" + ":" + (String)(8080) + "/");
Serial.println("setup done ");
}
void loop() {
Serial.println("\nDEBUG:\n new loop");
static double ftmp;
static unsigned long tsec = millis(), tms = millis();
Serial.println("\nDEBUG:\n handleWebsite()");
handleWebsite(); // <<<<<<<<<<<<<<<<<<<<<<<<<< runs through
Serial.println("\nDEBUG:\n webserver.handleClient()"); // <<<<<<<<<< runs through
webserver.handleClient();
//---------------------------------------
// Read local data
ftmp = -99;
//ftmp = bmp_x77.readTemperature();
Serial.println("\nDEBUG:\n ftmp");
Serial.println(ftmp);
//
}
void handleWebsite() {
WiFiClient client = wifiserver.available();
if (!client) {
Serial.println("\nDEBUG:\n !client => return");
return;
}
if(client) {
Serial.println("\nDEBUG:\n if(client true) => ...");
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
String script = "\n";
client.readStringUntil('\r');
Serial.println("\nDEBUG:\n script += (HTTP/1.1 200 OK \n) ");
script += ("HTTP/1.1 200 OK \n");
script += ("Content-Type: text/html \n");
script += ("\n");
script += ("<!DOCTYPE html> \n");
script += ("<html> \n");
// head + title
script += ("<head> \n");
// autom. Aktualisierung alle 20 sec.
script += "<meta http-equiv=\"refresh\" content=\"20; URL=";
script += (String)"myweb.sytes.net" + ":" + (String)(8080) + "\"> \n" ;
// utf-8 f眉r "掳" Zeichen
script += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n" ;
script += ("<title>");
script += "myweb.sytes.net";
script += ("</title> \n");
script += ("</head> \n");
// body + caption
script += ("<body> \n");
script += ("<h1> <p> ");
script += (String)"test" + " " + WiFi.localIP().toString() + " " + (String)ssid + " <br>" ;
script += "</p> </h1> \n";
script += "</body> \n";
script += "</html> \n";
script += ("<br> \n");
script += ("<br> \n");
Serial.println("\nDEBUG:\n client.print(script)");
client.print(script);
script = "";
}
delay(1);
Serial.println("\nDEBUG:\n end of handleWebsite()");
}
void handleRoot() {
;
Serial.println("\nDEBUG:\n handleRoot()");
}
void handleClients() {
;
Serial.println("\nDEBUG:\n handleClients()");
}
update:
after many seconds or even a couple of minutes I suddenly got intermediately again:
DEBUG:
handleWebsite()
DEBUG:
if(client true) => ...
GET / HTTP/1.1
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d1a10 PS : 0x00060630 A0 : 0x800d1ae4 A1 : 0x3ffb1e10
A2 : 0x00000000 A3 : 0x3ffb1e5f A4 : 0x00000001 A5 : 0x00000001
A6 : 0x00000000 A7 : 0x0a005054 A8 : 0x00000000 A9 : 0x00000000
A10 : 0x00000000 A11 : 0x00000080 A12 : 0x00000050 A13 : 0x3ffcbdb4
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0x00000008 LBEG : 0x400014fd LEND : 0x4000150d LCOUNT : 0xffffffff
Backtrace: 0x400d1a10:0x3ffb1e10 0x400d1ae1:0x3ffb1e30 0x4014270e:0x3ffb1e50 0x400d69d9:0x3ffb1e80 0x400d6a71:0x3ffb1ea0 0x400d13e2:0x3ffb1ec0 0x400d1783:0x3ffb1f90 0x400d8019:0x3ffb1fb0 0x40088b7d:0x3ffb1fd0
Rebooting...
ets Jun 8 2016 00:22:57
ets Jun 8 2016 00:22:57
rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:1044
load:0x40078000,len:8896
load:0x40080400,len:5816
entry 0x400806ac
Connecting to WiFi:
0.0.0.0
.
WiFi connected: 192.168.2.1
WiFi Server started
ESP webserver started
Use this URL to connect: http://192.168.2.201:80/
myweb.sytes.net:80/
setup done
DEBUG:
new loop
DEBUG:
handleWebsite()
DEBUG:
!client => return
DEBUG:
webserver.handleClient()
DEBUG:
ftmp
-99.00
DEBUG:
new loop
DEBUG:
handleWebsite()
DEBUG:
!client => return
PS,
also changing this didn't help:
//WiFi.config(this_ip, gateway, subnet, gateway, gateway); // dns = gateway
WiFi.config(this_ip,gateway,gateway,subnet);
@atanisoft
what do you mean by "connect to 8081"?
How should I do that?
what do you mean by "connect to 8081"?
How should I do that?
That is the port that the WebServer instance is using, though you won't get a webpage from it since the handlers are stubbed off in the code you have posted.
update:
after many seconds or even a couple of minutes I suddenly got intermediately again:
You will need to decode the new backtrace to get further on this.
what is the code to connect to 8081?
I still don't get a result if I c+p the backtrace into the Exception Decoder window, no reaction then.
@dsyleixa the only troll here is you. You refuse to comply to the norms for posting issues. Refuse to take some time and get the exception decoder working. Insulting fellow users. Should I continue? Novice, not novice, does not matter. There are minimum requirements for you to read and follow instructions.
I am closing this issue. Do not want another 60+ emails on this.
what an idiotic moderation!
@dsyleixa you are welcome to start a new issue with new attitude.