Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 20 15:20
    zekageri commented #1110
  • Jan 19 22:18
    pedros89 commented #1022
  • Jan 19 12:36
    stale[bot] unlabeled #1022
  • Jan 19 12:36
    stale[bot] commented #1022
  • Jan 19 12:35
    perotom commented #1022
  • Jan 18 21:04
    udiFi commented #975
  • Jan 18 14:22
    jmattioni opened #1112
  • Jan 18 11:22
    openedhardware commented #435
  • Jan 17 19:52
    alixti commented #1087
  • Jan 16 18:07
    marcpascualsanchez edited #1111
  • Jan 16 18:03
    marcpascualsanchez edited #1111
  • Jan 16 17:52
    marcpascualsanchez edited #1111
  • Jan 15 21:32
    marcpascualsanchez opened #1111
  • Jan 13 14:21
    PabloASua opened #1110
  • Jan 13 14:04
    weoiss1998 commented #1085
  • Jan 13 13:22
    stale[bot] unlabeled #979
  • Jan 13 13:22
    stale[bot] commented #979
  • Jan 13 13:22
    MoJo2600 commented #979
  • Jan 13 11:10
    videojedi commented #936
  • Jan 13 11:08
    videojedi commented #936
OnurNP
@K0rkunc
how to fix that
my html document
backtrace

Backtrace: 0x4000c3f0:0x3ffd1380 0x400db076:0x3ffd13a0 0x400db192:0x3ffd13c0 0x400d7ad1:0x3ffd13e0 0x400d6192:0x3ffd1450 0x400d60f5:0x3ffd1490 0x400d145d:0x3ffd14b0 0x4015188f:0x3ffd14f0 0x400d9309:0x3ffd1510 0x400d6df1:0x3ffd1560 0x400d6eb5:0x3ffd15a0 0x400d7105:0x3ffd15f0 0x4014b7b1:0x3ffd1610 0x4014b82d:0x3ffd1650 0x4014bed6:0x3ffd1670 0x4008a286:0x3ffd16a0

#0 0x4000c3f0:0x3ffd1380 in ?? ??:0

#1 0x400db076:0x3ffd13a0 in String::move(String&) at C:\Users\OnurNP.platformio\packages\framework-arduinoespressif32\cores\esp32/WString.cpp:857

#2 0x400db192:0x3ffd13c0 in String::operator=(String&&) at C:\Users\OnurNP.platformio\packages\framework-arduinoespressif32\cores\esp32/WString.cpp:857

#3 0x400d7ad1:0x3ffd13e0 in AsyncBasicResponse::_respond(AsyncWebServerRequest) at lib\ESPAsyncWebServer\src/WebResponses.cpp:699

#4 0x400d6192:0x3ffd1450 in AsyncWebServerRequest::send(AsyncWebServerResponse
) at lib\ESPAsyncWebServer\src/WebRequest.cpp:797

#5 0x400d60f5:0x3ffd1490 in AsyncWebServerRequest::send(int, String const&, String const&) at lib\ESPAsyncWebServer\src/WebRequest.cpp:797

#6 0x400d145d:0x3ffd14b0 in handleRoot(AsyncWebServerRequest) at src/main.cpp:289

#7 0x4015188f:0x3ffd14f0 in std::_Function_handler<void (AsyncWebServerRequest
), void ()(AsyncWebServerRequest)>::_M_invoke(std::_Any_data const&,

AsyncWebServerRequest*&&) at c:\users\onurnp.platformio\packages\toolchain-xtensa32@2.50200.97\xtensa-esp32-elf\include\c++\5.2.0/functional:1871

#8 0x400d9309:0x3ffd1510 in std::function<void (AsyncWebServerRequest*)>::operator()(AsyncWebServerRequest*) const at lib\ESPAsyncWebServer\src/StringArray.h:73

  (inlined by) AsyncCallbackWebHandler::handleRequest(AsyncWebServerRequest*) at lib\ESPAsyncWebServer\src/WebHandlerImpl.h:132

#9 0x400d6df1:0x3ffd1560 in AsyncWebServerRequest::_parseLine() at lib\ESPAsyncWebServer\src/WebRequest.cpp:797

#10 0x400d6eb5:0x3ffd15a0 in AsyncWebServerRequest::_onData(void, unsigned int) at lib\ESPAsyncWebServer\src/WebRequest.cpp:797

#11 0x400d7105:0x3ffd15f0 in std::_Function_handler<void (void
, AsyncClient, void, unsigned int), AsyncWebServerRequest::AsyncWebServerRequest(AsyncWebServer, AsyncClient)::{lambda(void, AsyncClient, void, unsigned int)#8}>::_M_invoke(std::_Any_data const&, void&&, AsyncClient*&&, std::_Any_data const&, unsigned int&&) at lib\ESPAsyncWebServer\src/WebRequest.cpp:797

  (inlined by) _M_invoke at c:\users\onurnp\.platformio\packages\toolchain-xtensa32@2.50200.97\xtensa-esp32-elf\include\c++\5.2.0/functional:1871    

#12 0x4014b7b1:0x3ffd1610 in std::function<void (void*, AsyncClient*, void*, unsigned int)>::operator()(void, AsyncClient, void*, unsigned int) const at lib\AsyncTCP\src/AsyncTCP.cpp:1039

  (inlined by) AsyncClient::_recv(tcp_pcb*, pbuf*, signed char) at lib\AsyncTCP\src/AsyncTCP.cpp:934

#13 0x4014b82d:0x3ffd1650 in AsyncClient::_s_recv(void, tcp_pcb, pbuf, signed char) at lib\AsyncTCP\src/AsyncTCP.cpp:1039

#14 0x4014bed6:0x3ffd1670 in _async_service_task(void
) at lib\AsyncTCP\src/AsyncTCP.cpp:1039

  (inlined by) _async_service_task at lib\AsyncTCP\src/AsyncTCP.cpp:197

#15 0x4008a286:0x3ffd16a0 in vPortTaskWrapper at

/home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c:355 (discriminator 1)

how to fix that help me
mesutaydeger
@mesutaydeger
"I made a simple class from AsyncTCP but am at a loss how to set a timeout." : Could you tell me briefly what to do? Can I put in AT commands?
notsolowki
@notsolowki
Hi!! anyone around?
OnurNP
@K0rkunc
im activated external interrupt and cant connect wifi
how to fix that
OnurNP
@K0rkunc
hi
how do use rtos on async web server
Ramses Garcia Dilone
@ramsesgarciad
hello world
i tried use this lib with w5500
is possible?
oldfogie
@oldfogie

Using AsyncWebServer on ESP32 I'm getting frequent Guru Meditation Errors:
Core 1 panic'ed (LoadProhibited). Exception was unhandled.
Core 1 register dump:
PC : 0x400d7e7c PS : 0x00060430 A0 : 0x800d7f1a A1 : 0x3ffb1f00
A2 : 0x3ffd31bc A3 : 0x3ffd2f84 A4 : 0x00000026 A5 : 0x3ffd2caa
A6 : 0x00000a0d A7 : 0x3a617461 A8 : 0x800d7e88 A9 : 0x3ffb1ee0
A10 : 0xe0088080 A11 : 0x00000026 A12 : 0x00000026 A13 : 0x00000026
A14 : 0x00000000 A15 : 0x00000000 SAR : 0x0000000a EXCCAUSE: 0x0000001c
EXCVADDR: 0xe0088088 LBEG : 0x4000c2e0 LEND : 0x4000c2f6 LCOUNT : 0xffffffff

ELF file SHA256: 0000000000000000

Backtrace: 0x400d7e7c:0x3ffb1f00 0x400d7f17:0x3ffb1f20 0x400d7f37:0x3ffb1f40 0x400d7f8d:0x3ffb1f60 0x400d17d3:0x3ffb1f90 0x400df329:0x3ffb1fb0 0x40089afa:0x3ffb1fd0

the backtrace shows
Decoding 7 results
0x400d7e7c: AsyncEventSourceClient::_runQueue() at c:\arduinoideportable\portable\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 1858
0x400d7f17: AsyncEventSourceClient::_queueMessage(AsyncEventSourceMessage) at c:\arduinoideportable\portable\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 1858
0x400d7f37: AsyncEventSourceClient::write(char const
, unsigned int) at c:\arduinoideportable\portable\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 1858
0x400d7f8d: AsyncEventSource::send(char const, char const, unsigned int, unsigned int) at c:\arduinoideportable\portable\packages\esp32\tools\xtensa-esp32-elf-gcc\1.22.0-97-gc752ad5-5.2.0\xtensa-esp32-elf\include\c++\5.2.0/functional line 1858
0x400d17d3: loop() at C:\ArduinoIDEPortable\portable\sketchbook\ESP32\SolarLoggerJune12/SolarLoggerJune12.ino line 151
0x400df329: loopTask(void*) at C:\ArduinoIDEPortable\portable\packages\esp32\hardware\esp32\1.0.6\cores\esp32/main.cpp line 23
0x40089afa: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib-builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 355 (discriminator 1)

referring to this line in my code

151: events.send( mycWatts , "cwatts", millis());

It doesntt happen every time but its realy giving me a headache. Any ideas?

Rolf Wedermann
@rolfwedermann
Hello everyone, will the ESP Async web server be further developed or is the project idle?
zekageri
@zekageri
Seems idle
Tom Sciano
@TSciano_twitter
how can I send a fetch/post request to itself using javascript
i keep getting a cors error
` const button = document.getElementById("post-btn");
    button.addEventListener("click", async(_) => {
        try {
            const response = await fetch("board", {
                method: "post",
                body: {
                   "id":1,
                   "t1":2,
                   "t2":3
                }
            });
            console.log("Completed!", response);
        } catch (err) {
            console.error(`Error: ${err}`);
        }
    }); `
Tom Sciano
@TSciano_twitter
+and this is how my post starts
AsyncCallbackJsonWebHandler *handler = new AsyncCallbackJsonWebHandler("/board", [](AsyncWebServerRequest *request, JsonVariant &json) {
also tried with adding this before server begin
DefaultHeaders::Instance().addHeader("Access-Control-Allow-Origin", "*"); DefaultHeaders::Instance().addHeader("Access-Control-Allow-Headers", "Content-Type");
johnerrington
@johnerrington
Re my message above I have found that my code is much more stable - ie less frequent guru errors - with a delay between events.send calls.
I've implemented this with a state machine and have not had a guru error in 24 hours continuous running (but there is time yet!)
Daniel
@ld21

I'm trying to let ESPAsynchWebServer on an ESP32 serve all JPG-Images in SPIFFS as follows:

server->on("^(([/|.|\w|\s])*)\.jpg$", HTTP_GET, [] (AsyncWebServerRequest *request) { String name = request->pathArg(0) + ".jpg"; request->send(SPIFFS, name, "image/jpg"); });

Unfortunatel, it never serves the images.

I added compiler.cpp.extra_flags=-DDASYNCWEBSERVER_REGEX to platforms.local.txt
The files are called like «aed3.jpg» oder «bcd.jpg».
If anyone sees how I sould change the regex to mach my needs, please help me.

Thank you very much, Dani

sillyfrog
@sillyfrog
@ld21 Have you tried the server.serveStatic setup? I have used that for some time now and find it the best way to serve files. You should be able to just serve the files from a specific directory (I have not tried, I always use the root directory), and you could put your .jpg in there. See here for an example usage in one of my projects: https://github.com/sillyfrog/PrettyLights2/blob/bbed6c986609ad2b17e7be4eaa7f512c87c81b75/src/main.cpp#L839 (this code allows you to change between LittleFS and SPIFFS - now SPIFFS is EOL I would suggest moving to LittleFS for a new project).
Daniel
@ld21
@sillyfrog Great ideas, thanks a lot – I think they will solve my problems in a very elegant way. And thanks for pointing out LittleFS, I havent's heard of it so far and it really seems to be the future of ESP32-FSs.
Ora Prints
@Oraprints
Ora prints is one of the best printing and packaging platforms where different kinds of Gift boxes and depictions are made. https://oraprints.com/
OnurNP
@K0rkunc

Hello

I am running the interface on the local server using the asyncy web server library. no problem here

but 2 or more esp32s are connecting to each other, the server esp32 needs to send data to the client esp32, for this they need to send data between themselves via http post. How can I do this?

Baba Boota
@bababoota
Baba boota is best online shopping website in Pakistan, where you get all of your daily need products with one click. We provide you with all the things at a reasonable price and good quality, so sit back and order your stuff from Baba Boota.com https://bababoota.com
Pavel Baranov
@7doctor7
Hi
guys, does anyone tried to use ESP32 miniz lib to compress files on sd card?
maybe someone can provide a simple working example?
Sloata George
@GeorgeFlorian

Are there any examples of dynamic web pages using ESPAsyncWebServer ?
I would like to GET and POST data without having to reload the page every time.

Right now each request ends with redirect which reloads the page:

  server.on("/settings", HTTP_POST, [](AsyncWebServerRequest *request)
            {
              if (request->hasArg("save_output"))
              {
                // do something with the received data
                request->redirect("/settings");
              }
              else
              {
                request->redirect("/settings");
              }
            });

But request->redirect("/settings"); reloads the page.
Can I change this behavior ?

Anthony
@ARprogramer_twitter
Hi I am new to programing and Arduino can you please anyone help me out I'm stuck on this error code :
C:\Users----\Documents\Arduino\libraries\ESPAsyncTCP-master\src\SyncClient.cpp:25:24: fatal error: interrupts.h: No such file or directory
compilation terminated.
exit status 1
Error compiling for board ESP32 Dev Module.
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
I downloaded * ArduinoJson (Request Pool Version 2.6)
Anthony
@ARprogramer_twitter
What did I not include or configure?
Anthony
@ARprogramer_twitter
I'm using a ESP32s wroom board 38pin. Sorry if I seem to be spamming I'm just trying to include the information needed to complete compilation and understand the libraries for the sketch to verify so I can then upload.
Mick Percy
@DeeEmm

@GeorgeFlorian you need to exchange data between server and client using websockets. This means you need to create your own protocols for exchanging data and updating the DOM.

I'm currently doing this on a project that I am working on... https://github.com/DeeEmm/DIY-Flow-Bench/tree/ESP32

The way that I have done this is that both the browser and ESP32 have websocket listen events. I'm exchanging JSON data and adding a header value to each JSON object before transmission. The header acts as a simple protocol to let the receiving side know what to do. When websocket data is received the JSON 'header' value is decoded and the relevant action taken. Some transmissions only have a header value, others have the header value with additional data. This data exchange is both bidirectional and asynchronous so falls outside of the main loop.

On the browser side you can update the DOM using simple document.getElementById statements

Check out the index.html / javascript.js files for the client implementation and the Webserver::ProcessWebSocketMessage method in Webserver.cpp for the ESP side.

For an example of the JSON data I am using take a look in data/config.json

Using JSON makes the data exchange nice and easy on both sides as there are already tools available for both the browser (native javascript) and ESP32 (ArduinoJson library) to manage JSON data objects. It also makes storing configuration data in SPIFFS nice and easy too.

There is one caveat to this - file uploads - Traditionally they are handled via POST vars and require a navigation event (file / form submit) to transmit them. HTML5 does have a transport method that does not require this but I have not played with it (yet) so cannot comment. However it appears that this method is not backwards compatible in older browsers.

/DM

Mick Percy
@DeeEmm
@GeorgeFlorian In your example you show 'settings'. The way that I have dealt with this is to use a modal dialog that is hidden. This is unhidden using simple javascript trigger by a user on-click event. In fact there are several such dialogs / tabs that are all within the one index.html page and are hidden / unhidden accordingly. This gives the impression of navigation without any form of redirect or page reload.
Apoorva Singh
@meticulouscraftman:matrix.org
[m]
Hello everyone,
Is there any example that shows how to setup a loopback connection to a server built using ESPAsyncWebServer.
I tried using the IP address of the device using the ESP8266's WiFiClient library. But for some reason it's unable to connect to the server.
My goal is to run a server as well as have a client connection on the same ESP8266 that forwards HTTP requests from a different source to ESPAsyncWebServer. If you guys can point me towards some resources, it would be very helpful. Thank you!
Sloata George
@GeorgeFlorian

Hello.

I encountered this project: https://github.com/DroneBridge/ESP32 and I saw that the web-page works flawlessly and the information on page change without refreshing the page even on submit.

I am using this web-server for my projects and each time I submit data (POST) to the server I redirect to the same page, meaning that I reload the page.

This is a GET handler:

    server.on("/home", HTTP_GET, [](AsyncWebServerRequest *request)
              { request->send(SPIFFS, "/index.html", "text/html", false, processor); });

This is a POST handler:

  server.on("/home", HTTP_POST, [](AsyncWebServerRequest *request)
            {
              if (request->hasArg("send_data_when_submit_btn_pressed"))
              {
                int params = request->params();
                for (int i = 0; i < params - 1; i++)
                {
                  AsyncWebParameter *p = request->getParam(i);
                  if (p->isPost() && p->value().length() > 0 && p->value() != "#000000")
                  {
                    if (p->name() == "brightness")
                      Brightness = p->value();
                  }
                }
                request->redirect("/home");
              }
              else if (request->hasArg("toggle_btn"))
              {
                outputFlag = !outputFlag;
                String str = outputFlag ? "On" : "Off";
                request->redirect("/home");
              }
              else
              {
                request->redirect("/home");
              }
            }); // server.on("/home", HTTP_POST, [](AsyncWebServerRequest * request)

As you can see, for each action I am required to use request->redirect("/home"); which reloads the page when redirecting.

Also, I am currently using AJAX calls to refresh or change data on the page without reloading the page:

var text_box = document.querySelector('.text_box');

if (text_box != null || rs1 != null || rs2 != null) {
    function refresh() {
        setTimeout(function () {
            if ($('.text_box').length) $('.text_box').load('events_placeholder.html');
            refresh();
        }, 1000);
    }

    $(document).ready(function () {
        if ($('.text_box').length) $('.text_box').load('events_placeholder.html');
        refresh();
    });
}

This makes a call to the events_placeholder.html each second and it seems resource consuming.
Is there a better way of doing this ?

Is it possible to implement a framework like VueJS for example on this web-server ?

Louis Lewis
@louislewis2

Hi everyone,

I have looked at the documentation regarding handling post requests, but I cannot seem to find the answers I am looking for.
I am porting some code which was using the plain WebServer implementation. With that implementation I have multiple post requests being used like this

this->webServer->on("/api/configuration/wifi", HTTP_POST, [this]()
{
    String data = this->webServer->arg("plain");

    DynamicJsonDocument doc(500);
    DeserializationError error = deserializeJson(doc, data);

        // rest of code omitted.......
}

this->webServer->on("/api/configuration/timer", HTTP_POST, [this]()
{
    String data = this->webServer->arg("plain");

    DynamicJsonDocument doc(500);
    DeserializationError error = deserializeJson(doc, data);

        // rest of code omitted.......
}

I was reading about the onRequestBody method, which I tried using.

this->webServer.onRequestBody([this](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total)
{
  if (request->url() == "/api/configuration/wifi")
  {
      this->HandleWifiConfig(request, data);
  }
});

With the above, In the HandleWifiConfig method does indeed get called, it does return a response, using

 request->send(200, "application/json", "testing");

However the onNotFound handler still gets called.

Am I still meant to register a handler using "webServer.on(......"?
If so, what would the signature look like?

On the client side, I am doing a normal http post request, with the body being set to json.
I am not too keen on using the Json handler as documented, I would rather stick to my manual parsing for the moment, its been working for a year.

Thanks

Louis Lewis
@louislewis2
Louis Lewis
@louislewis2

Good evening,

I ran into an issue, hopefully someone can assist.
I have two endpoints

    this->webServer.on("/api/configuration/wifi", HTTP_GET, [this](AsyncWebServerRequest *request)
                       {
                           AsyncWebServerResponse *response = request->beginResponse(200, "application/json", wifiManager.GetConfigurationAsString());
                           response->addHeader("Access-Control-Allow-Origin", "*");

                           request->send(response);
                       });

    this->webServer.on("/api/configuration/wifi/status", HTTP_GET, [this](AsyncWebServerRequest *request)
                       {
                           WiFiStatus wifiStatus = wifiManager.GetStatus();

                           AsyncWebServerResponse *response = request->beginResponse(200, "application/json", wifiStatus.ToString());
                           response->addHeader("Access-Control-Allow-Origin", "*");

                           request->send(response);
                       });

I am calling this endpoint http://192.168.4.1/api/configuration/wifi/status
Which should map to the second endpoint above, however it is the first one that gets executed.

Am I doing something wrong?

Mike Dunston
@atanisoft
swap the order of them
put the /api/configuration/wifi/status one first
Louis Lewis
@louislewis2
Awesome, thanks once again Mike.
Worked like a charm
Mike Dunston
@atanisoft
np
Brad Nelson
@bnelson796:matrix.org
[m]
What is the easiest way to determine if a client has connected to Espasyncwebserver?
Sloata George
@GeorgeFlorian

How can I serve the css and js files without an actual path ? Let's say we have the following handler:

  server.on("/script.js", HTTP_GET, [](AsyncWebServerRequest *request)
            {
              AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/script.js.gz", "text/javascript");
              response->addHeader("Content-Encoding", "gzip");
              request->send(response);
            });

If the user goes to /script.js he will have access to the file and this seems like a security issue.

1 reply