GithubHelp home page GithubHelp logo

Comments (5)

mruettgers avatar mruettgers commented on June 22, 2024

Hi,

First of all, thank you for your great work on this library.

I'm encountering the same issue here with v1.7.0. It looks like the web server is returning garbage after some valid bytes (see screenshot attached).

The garbage occurrs after:
<!DOCTYPE html><html lang="en"><head><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/><title>Config ESP</title><script>function c(l){document.getElementById('s').value=l.innerText||l.textContent;document.getElementById('p').focus();document.getElementById('s1').value=l.innerText||l.textContent;document.getElementById('p1').focus();}</script><script>(function(e){var t=function(){"use strict";var e="s",n=function(e){var t=-e.getTimezoneOffset();return t!==null?t:0},r=function(e,t,n){var r=new Date;return e!==undefined&&r.setFullYear(e),r.setDate(n),r.setMonth(t),r},i=function(e){return n(r(e,0,2))},s=function(e){return n(r(e,5,2))},o=function(e){var t=e.getMonth()>7?s(e.getFullYear()):i(e.getFullYear()),r=n(e);return t-r!==0},u=function(){var t=i(),n=s(),r=i()-s();return r<0?t+",1":r>0?n+",1,"+e:t+",0"},a=function(){var e=u();return ne

Bildschirmfoto 2021-04-29 um 22 14 56

Thanks,
Michael

from espasync_wifimanager.

mruettgers avatar mruettgers commented on June 22, 2024

Hm. It looks like the issue is caused by passing the page variable of type String by value.

Replacing
AsyncWebServerResponse *response = request->beginResponse(200, WM_HTTP_HEAD_CT, page);

with
AsyncWebServerResponse *response = request->beginResponse_P(200, WM_HTTP_HEAD_CT, page.c_str());

in
void ESPAsync_WiFiManager::handleWifi(AsyncWebServerRequest *request)

solves the issue for me.

And because there's no need to do memory operations for building the response, we should always use beginResponse_P and pass the char pointer to avoid string duplication in memory and an oom error.
Unfortunately I don't have the time for a pull request right now, maybe within the next days.

from espasync_wifimanager.

khoih-prog avatar khoih-prog commented on June 22, 2024

@glen361

Thanks for using the library.
I've retried many times, using WeMos D1 Mini as well as WeMos D1, ESP3288, etc. but everything is OK.

Starting Async_ConfigOnDoubleReset using LittleFS on ESP8266_WEMOS_D1MINI
ESPAsync_WiFiManager v1.7.1
ESP_DoubleResetDetector v1.1.1
ESP Self-Stored: SSID = HueNet, Pass = password
[WM] * Add SSID =  HueNet , PW =  password
Got ESP Self-Stored Credentials. Timeout 120s for Config Portal
LittleFS Flag read = 0xD0D01234
doubleResetDetected
Saving config file...
Saving config file OK
Open Config Portal without Timeout: Double Reset Detected
Starting configuration portal @ 192.168.4.1, SSID = ESP_AB1481, PWD = MyESP_AB1481
[WM] Connecting to new AP
WiFi connected...yeey :)
[WM] * Add SSID =  HueNet1 , PW =  password
[WM] * Add SSID =  HueNet2 , PW =  password
[WM] SaveWiFiCfgFile 
[WM] stationIP = 192.168.2.186 , gatewayIP = 192.168.2.1
[WM] netMask = 255.255.255.0
[WM] dns1IP = 192.168.2.1 , dns2IP = 8.8.8.8
[WM] OK
After waiting 0.00 secs more in setup(), connection result is connected. Local IP: 192.168.2.186
HHH

I think there is something wrong either with your board, your code or your development platform (Visual Code Studio). I suggest you to eliminate the issue one-by-one, by using the standard Arduino IDE v1.8.13 on another ESP8266 board.

You have to know ESP32 is more powerful with larger resource than ESP8266. Therefore code, running on ESP32, can't always run on ESP8266.

I have to close the issue until you prove there is some bug in the library.

Good Luck,

from espasync_wifimanager.

glen361 avatar glen361 commented on June 22, 2024

from espasync_wifimanager.

khoih-prog avatar khoih-prog commented on June 22, 2024

@mruettgers

I don't think that is the issue. If you have a look at the ESPAsyncWebServer library #L246-L254

AsyncWebServerResponse *beginResponse(int code, const String& contentType=String(), const String& content=String());

...

AsyncWebServerResponse *beginResponse_P(int code, const String& contentType, PGM_P content, AwsTemplateProcessor callback=nullptr);

The following function call is correct, and String is passed by reference, not by value (with duplication) as you think.

AsyncWebServerResponse *response = request->beginResponse(200, WM_HTTP_HEAD_CT, page);

The following call to use beginResponse_P is wrong, unless your page is PGM_P type (in PROGMEM)

AsyncWebServerResponse *response = request->beginResponse_P(200, WM_HTTP_HEAD_CT, page.c_str());

I suggest you to check your code as well as your usage of your String for heap / stack corruption issue.

from espasync_wifimanager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.