Skip to content
This repository was archived by the owner on Jan 20, 2025. It is now read-only.

Server's pretty slow #535

Closed
GeorgeFlorian opened this issue Jun 28, 2019 · 0 comments
Closed

Server's pretty slow #535

GeorgeFlorian opened this issue Jun 28, 2019 · 0 comments

Comments

@GeorgeFlorian
Copy link

GeorgeFlorian commented Jun 28, 2019

Hello ! It's me again.

This time I am reporting that the Server seems slower than a couple of weeks ago. I haven't changed my code since then. I actually made the CSS and HTML lighter.
All of the files are minified and sent to the server using SPIFFS.

While the ESP32 is in AP mode, the ESPAsyncWebServer gets hangs and I get some "infinite loading" after some time. The first 2-3 refreshes work well.
While it does NOT crash it sends me warnings:

[W][AsyncTCP.cpp:903] _poll(): rx timeout 4
[W][AsyncTCP.cpp:903] _poll(): ack timeout 4

Closing the browser and trying again seems to fix it.

While in STATION mode, it works fairly fine for an undefined period of time, even after multiple refreshes.

The only thing that I do not like in this situation is the fact that it's slow and after long-ish period of times in which a web-page was left open in the browser, upon refreshing the page or clicking a submit button, it sends either one of the following warnings or both:

[W][AsyncTCP.cpp:883] _poll(): pcb is NULL
[W][AsyncTCP.cpp:903] _poll(): rx timeout 4

Accessing any page, refreshing, saving inputs value by pressing submit buttons and changing pages all take around 10 seconds to perform. It didn't take this long.

Here is some code.
These are all the handlers I use for a simple log-in page:

 server.on("/register", HTTP_GET, [](AsyncWebServerRequest *request){              
    request->send(SPIFFS, "/indexAP.html", "text/html");
  });
  server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){              
    request->redirect("/register");
  });
  server.on("/register", HTTP_POST, [](AsyncWebServerRequest * request){
    int params = request->params();
    String values_user[2];
    for(int i=0;i<params;i++){
      AsyncWebParameter* p = request->getParam(i);
      if(p->isPost()){
          logOutput((String)"POST[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");            
          values_user[i] = p->value();            
        } else {
            logOutput((String)"GET[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
          }
    } // for(int i=0;i<params;i++)
    
    if(values_user[0] != NULL && values_user[0].length() > 4 &&
      values_user[1] != NULL && values_user[1].length() > 7) {
          File userWrite = SPIFFS.open("/user.txt", "w");
          if(!userWrite) logOutput((String)"ERROR_INSIDE_POST ! Couldn't open file to write USER credentials !");
          userWrite.println(values_user[0]);  // Username
          userWrite.println(values_user[1]);  // Password
          userWrite.close();
          logOutput("Username and password saved !");          
          request->redirect("/IP-Config");
          // digitalWrite(LED, LOW);
    } else request->redirect("/register");  
  }); // server.on("/register", HTTP_POST, [](AsyncWebServerRequest * request)

  server.on("/button", HTTP_POST, [](AsyncWebServerRequest * request){
    int params = request->params();
    String values_button = "";
    for(int i=0;i<params;i++){
      AsyncWebParameter* p = request->getParam(i);
      if(p->isPost()){
          logOutput((String)"POST[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");            
          values_button = p->value();            
        } else {
            logOutput((String)"GET[" + p->name().c_str() + "]: " + p->value().c_str() + "\n");
          }
    } // for(int i=0;i<params;i++)
    values_button.trim();
    if(values_button == "Skip") {
      request->redirect("/IP-Config");
    }   
  });
  server.on("/newMaster.css", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/newMaster.css", "text/css");
  });
  server.on("/jquery-1.12.4.min.js", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/jquery-1.12.4.min.js", "text/javascript");
  });
  server.on("/logo.png", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SPIFFS, "/logo.png", "image/png");
  });

While the HTML for this particular page doesn't have any JS on it, I felt like I had to mention that the server has a handler that sends a 99 kB JS file whenever it needs to.

<!DOCTYPE html>
<html>    
<head>
    <meta charset = "utf-8">
    <meta name = "viewport" content = "width=device-width, initial-scale=1.0">
    <!-- Chrome, Firefox OS and Opera -->
    <link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png?v=476mA4zprB">
    <link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png?v=476mA4zprB">
    <link rel="shortcut icon" href="/favicon.ico?v=476mA4zprB">
    <!-- Tab Color iOS Safari -->
    <meta name="apple-mobile-web-app-title" content="#e11422">
    <meta name="application-name" content="#e11422">
    <!-- Tab Color Android Chrome -->
    <meta name="theme-color" content="#e11422">

    <link rel = "stylesheet" type = "text/css" href = "newMaster.css">   
    <title>Login Page</title>
       
</head>

<body>
    <div class = "logo_container"> <img url="/logo.png"></div>
    <div class="center_box">
        <div class = "box_head">
            <div class = "title"><h1>Setup - User</h1></div>
        </div>
        <form method = "post" action="/register">
            <div class ="text_input">            
                <input type="text" placeholder="Username" name="userName" value="" pattern=".{5,30}" required title="Enter between 5 and 30 characters">
            </div>        
            <div class="text_input">            
                <input type="password" placeholder="Password" name="userPassword" value="" pattern=".{8,63}" required title="Enter between 8 and 63 characters">
            </div>
            <input class = "button" type="submit" name="register" value="Save" >
        </form>
        <form method = "post" action = "/button">
            <input class = "button" type="submit" name="skip" value="Skip" title = "Proceed to IP Configuration page">
        </form>
    </div>
</body>  
    
</html>

I am using two forms in this page, like I do in some other pages that are on the web-server.

The first one is to save the values that someone will input. It redirects to the next page by using: request->redirect("/IP-Config");.

The second one is to skip the user creation and jump straight to the next page. And this form is somewhat different from the first one. For this redirect to work I had to make a server handler for the button: server.on("/button", HTTP_POST, [](AsyncWebServerRequest * request) that then redirects the user to the desired page: request->redirect("/IP-Config");.

EDIT:

After an hour of letting the ESP32 in STA Mode and a web-page open in the browser I got a Guru Meditation Error:

Guru Meditation Error: Core  0 panic'ed (LoadProhibited). Exception was unhandled.
Core 0 register dump:
PC      : 0x4010ff5e  PS      : 0x00060630  A0      : 0x8010bb26  A1      : 0x3ffd50b0  
A2      : 0x3ffdfa84  A3      : 0x00000020  A4      : 0x00000002  A5      : 0x3ffb9c40  
A6      : 0x00000000  A7      : 0x3ffd45e0  A8      : 0x3741a32b  A9      : 0xabba13d7  
A10     : 0x74786574  A11     : 0x000001a3  A12     : 0xabba1234  A13     : 0x00000b38  
A14     : 0x00000020  A15     : 0x00000000  SAR     : 0x00000019  EXCCAUSE: 0x0000001c  
EXCVADDR: 0x00000030  LBEG    : 0x4000c2e0  LEND    : 0x4000c2f6  LCOUNT  : 0xffffffff  

Backtrace: 0x4010ff5e:0x3ffd50b0 0x4010bb23:0x3ffd50e0 0x401377d9:0x3ffd5100 0x401084d8:0x3ffd5120 0x400887fd:0x3ffd5150
0x400887fd: rtc_clk_slow_freq_set at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/soc/esp32/rtc_clk.c line 256

The issue with this is that after the reboot, the code that's on the ESP32 does NOT work. The serial monitor doesn't say a thing. I have to manually reset the ESP by pressing the on-board reset button.

@GeorgeFlorian GeorgeFlorian changed the title Server pretty slow Server's pretty slow Jun 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant