by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:05
    stale[bot] unlabeled #745
  • 06:05
    stale[bot] commented #745
  • 06:05
    BbIKTOP commented #745
  • 04:10
    stale[bot] labeled #745
  • 04:10
    stale[bot] commented #745
  • Aug 09 22:29
    stale[bot] labeled #769
  • Aug 09 22:29
    stale[bot] commented #769
  • Aug 09 18:47
    TomaszKisiel commented #817
  • Aug 09 13:29
    stale[bot] closed #694
  • Aug 09 13:29
    stale[bot] closed #744
  • Aug 09 13:29
    stale[bot] commented #694
  • Aug 09 13:29
    stale[bot] commented #744
  • Aug 08 16:26
    cgmckeever commented #489
  • Aug 08 06:11
    stale[bot] labeled #786
  • Aug 08 06:11
    stale[bot] commented #786
  • Aug 07 00:48
    cgmckeever commented #820
  • Aug 07 00:48
    cgmckeever opened #822
  • Aug 07 00:01
    cgmckeever commented #820
  • Aug 06 22:06
    cgmckeever commented #820
  • Aug 06 22:06
    cgmckeever opened #821
Ghost
@ghost~5eb4efb0d73408ce4fe31278
I am a beginner developer learning Arduino.
Alexandr Zarubkin
@me21
If it is related to espasyncwebserver; what board do you use?
Jan Theiss
@nixmeer

Hello :) I have a simple server application that makes the esp32 crash after every second request. Here is what it looks like:

void handleRoot(AsyncWebServerRequest *request) {
  if (request->hasParam("Volumenstromsollwert")) {
    if (!trainingGrnn) {
      controller.setW(lPerMin2percent(request->getParam("Volumenstromsollwert")->value().toFloat()), micros());
    }
  }
  request->send(200, "text/html", String(website1 + percent2lPerMin(controller.getW()) + website2));
}

Any idea why this happens?

Mike Dunston
@atanisoft
@nixmeer without seeing the crash reason we can only speculate. But I would suspect the call to controller.setW() is a blocking call and if so that is why it is crashing and restarting.
kalach
@mrkalach_twitter
Hellou everybody! Question: is there any documentation about what I can do in AsyncWebserver and AsyncWebSocket handlers and what I cannot, should I disable interrupts inside the handler, or how it manages to do some long task in handler? Another question: my app continually(every 2 seconds) sending data via textAll() call, and I'm getting random crashes. If somebody still alive there, I'll post crash logs. ps. hardware is esp2866
kalach
@mrkalach_twitter
and exception example:
Exception (29):
epc1=0x4020b7de epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000008 depc=0x000                         00000

StoreProhibited: A store referenced a page mapped with an attribute that does not permit stores
  epc1=0x4020b7de in AsyncWebSocketMultiMessage::AsyncWebSocketMultiMessage(AsyncWebSocketMessageBuffer*, unsigned char, bool) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.h:117
     (inlined by) AsyncWebSocketMultiMessage::AsyncWebSocketMultiMessage(AsyncWebSocketMessageBuffer*, unsigned char, bool) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.cpp:393

>>>stack>>>

ctx: cont
sp: 3ffffd50 end: 3fffffc0 offset: 0190
3ffffee0:  00000000 3fff6b8c 3fffbfa4 4020c18a
3ffffef0:  3fff045c 3fff03b8 3fffbfa4 4020ca1b
3fffff00:  3fff698c 3fffff10 00000004 00000000
3fffff10:  3fff045c 3fff03b8 3fff03b8 4020ca52
3fffff20:  38000000 00000090 3fff05b0 4020ca7d
3fffff30:  1cc5c844 00000004 3fff03b4 40201cf4
3fffff40:  3fffdad0 3fff03b4 3fff035c 402092ae
3fffff50:  00000004 426c008b 00000020 00000005
3fffff60:  42380d49 605ffaf0 14051a00 401006e4  
3fffff70:  00000000 3fff4574 3fff021c 3fff100c
3fffff80:  3fffdad0 00000000 3fff021c 40208540
3fffff90:  3fffdad0 00000000 3ffe862c 40207fd8
3fffffa0:  feefeffe feefeffe feefeffe 4021c8ab
3fffffb0:  feefeffe feefeffe feefeffe 40100c89
<<<stack<<<

0x4020c18a in AsyncWebSocketClient::text(AsyncWebSocketMessageBuffer*) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.cpp:807
0x4020ca1b in AsyncWebSocket::textAll(AsyncWebSocketMessageBuffer*) at .pio\libdeps\debug\ESP Async WebServer\src/StringArray.h:53
 (inlined by) AsyncWebSocket::textAll(AsyncWebSocketMessageBuffer*) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.cpp:962
0x4020ca52 in AsyncWebSocket::textAll(char const*, unsigned int) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.cpp:975
0x4020ca7d in AsyncWebSocket::textAll(char const*) at .pio\libdeps\debug\ESP Async WebServer\src/AsyncWebSocket.cpp:1107
0x40201cf4 in ESPUI::graphSetScale(unsigned short, float) at src/esp_ui.cpp:128
0x402092ae in WEBServer::update() at src/web_server.cpp:128
0x401006e4 in Timer::update() at src/timer.cpp:13
0x40208540 in State::update() at src/state.cpp:74
0x40207fd8 in loop at src/main.cpp:13
0x4021c8ab in loop_wrapper() at C:\Users\takul\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/core_esp8266_main.cpp:197
0x40100c89 in cont_wrapper at C:\Users\takul\.platformio\packages\framework-arduinoespressif8266\cores\esp8266/cont.S:81


last failed alloc call: 4020C18A(36)
Paytah232
@Paytah232
Is there an equivalent to server.hasArg("download") for this async web server? I want to use the FSBrowser example provided in arduino, but it obviously doesn't use async; so is there a drop in equivalent, or will I have to do some extra processing?
Me No Dev
@me-no-dev
request->hasArg()
Masaya Yumeda
@MasayaYumeda_twitter
Hi, I'm quite new to all this and currently trying to use AsyncWebServer with BleKeyboard (https://github.com/T-vK/ESP32-BLE-Keyboard) in Arduino IDE. I can get each of these working independently but for some reason when I try to run both at the same time, the web server does not seem to work. Can anyone help with a possible reason why this is happening and a solution for it? Thank you in advance.
Orlin Dimitrov
@orlin369
Hello, I have question guys. I am using ESPAsyncWEBServer. When I open a WEB socket connection for a reason after few seconds, my WEB browser application trying to reconnect, but at the same time on the serial console I am receiving message that more client are connected then the allowed number, how to close old connections on the server side? Thanks in advance. This is the application, its purpose is to monitor mobile robots on summits and events. Repo: https://github.com/orlin369/iotr
AFSand
@AlanFuller

Hi, I have a fully developed web server application for opening my garage door and I have written the server part using the ESPAsyncWebServer using “AsyncResponseStream” and “response->print” features. It is lightning fast but I would like to add a feature to stream the video from the integrated camera of an ESP32-CAM. I am trying to replicate the following code which is from another ESP32-CAM project which uses the standard ESPWebServer and WiFiClient interfaces:

String response = "HTTP/1.1 200 OK\r\n";
response += "Content-disposition: inline; filename=capture.jpg\r\n";
response += "Content-type: image/jpeg\r\n\r\n";
server.sendContent(response);
client.write((char *)cam.getfb(), cam.getSize());

I know I can send the basic HTML elements using the techniques I already have working but from the examples for AsyncWebServer I believe I need to use the chunkedResponse since the size of the JPEG data varies with each image capture. Can someone point me to a code snippet that might help me work out how to send the image as a chunked response please?

christian-0s
@christian-0s

Hello, I have a problem with UTF-8 characters in a json response with AsyncWebServer. Using standard WiFiServer of ESP32 Arduino core UTF-8 characters are printed correctly, while the same json string using AsyncWebServer shows garbled characters instead of the correct ones.

cLength = snprintf(json, sizeof(json), "{\"info\":{\"time\":\"%s\",\"ip\":\"%u.%u.%u.%u\",\"devicename\":\"%s\"},\"iostate\":{\"sensor\":[{\"name\":\"Temperatura\",\"number\":0,\"unit\":\"°C\",\"value\":%.1f},{\"name\":\"Umidità\",\"number\":1,\"unit\":\"%%\",\"value\":%.1f},{\"name\":\"Polvere\",\"number\":2,\"unit\":\"n/m³\",\"value\":%.0f}]},\"system\":{\"uptime\":%d}}", reading_time, ip[0], ip[1], ip[2], ip[3], EAP_IDENTITY, t, h, d, up_min);
client.println("HTTP/1.0 200 OK");
client.println("Access-Control-Allow-Origin: *");
client.println("Cache-Control: no-cache,private,max-age=0");
client.println("Content-Type: application/json; charset=utf-8");
client.println("Connection: close");
client.print(F("Content-Length: "));
client.println(cLength);
client.println();
client.println(json);

prints
{"info":{"time":"2020-06-09,06:39:09","ip":"10.227.125.139","devicename":"ESP32_SENS5"},"iostate":{"sensor":[{"name":"Temperatura","number":0,"unit":"°C","value":26.4},{"name":"Umidità","number":1,"unit":"%","value":47.6},{"name":"Polvere","number":2,"unit":"n/m³","value":93186}]},"system":{"uptime":603}}
while

AsyncResponseStream *response = request->beginResponseStream("application/json; charset=utf-8");
response->printf("{\"info\":{\"time\":\"%s\",\"ip\":\"%u.%u.%u.%u\",\"devicename\":\"%s\"},\"iostate\":{\"sensor\":[{\"name\":\"Temperatura\",\"number\":0,\"unit\":\"°C\",\"value\":%.1f},{\"name\":\"Umidità\",\"number\":1,\"unit\":\"%%\",\"value\":%.1f},{\"name\":\"Polvere\",\"number\":2,\"unit\":\"n/m³\",\"value\":%.0f}]},\"system\":{\"uptime\":%d,\"heap\":%d}}", reading_time, ip[0], ip[1], ip[2], ip[3], EAP_IDENTITY, t, h, d, up_min, ESP.getFreeHeap());
request->send(response);

prints
{"info":{"time":"2020-06-09,07:09:58","ip":"10.227.125.132","devicename":"ESP32TEST"},"iostate":{"sensor":[{"name":"Temperatura","number":0,"unit":"�C","value":28.1},{"name":"Umidit�","number":1,"unit":"%","value":42.7},{"name":"Polvere","number":2,"unit":"n/m�","value":82319}]},"system":{"uptime":0,"heap":212032}}
As you can see, characters °, à and ³ are not rendered correctly.
Any idea on what may cause this issue?

Alexandr Zarubkin
@me21
What's the encoding of the source file?
Oh, WiFiServer works. Never mind.
christian-0s
@christian-0s

What's the encoding of the source file?

There is no source file, i just print an hardcoded string. I forgot to mention I'm using Arduino IDE

Alexandr Zarubkin
@me21
I mean the source file which your program is written in
christian-0s
@christian-0s

I mean the source file which your program is written in

Ah ok, I think Arduino IDE uses UTF-8

Mehrdad K
@mkeyno
Hi all guy's, does anyone know a good project of using asyncwebserver with freertos on esp32
zekageri
@zekageri

I have got a problem with the http requests too. So far everything worked fine. Suddenly i wanted to send to the esp a json String and i always get garbage, but every time on the exact same spot inside the json string. On the web in js, the message looks okay, and when it get's sended and the esp32 sends it back to the server for me to be able to check the error, the message is not the same.

Here is the HTTP_GET where i want to save it to a file:

server.on("/SaveUserProg", HTTP_GET, [](AsyncWebServerRequest *request){
  String Response = "";
  int params = request->params();
  for(int i=0;i<params;i++){
    AsyncWebParameter* p = request->getParam(i);
    Response += p->value();
    Response += "↨";
  }
  AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", Response);
  response->addHeader("Access-Control-Allow-Origin","*");
  request->send(response);
});

Here is the Data Expected:
Here is the Corrupted Data:

As you can see, i don't do anything with it, just immediately send back.
Aaand the message is corrupt.

zekageri
@zekageri
Oh, the problem is with the % character in the end of the message. WTF
zekageri
@zekageri
Is it possible to xQueueSend a struct inside async callback?
server.on("/UserBtn", HTTP_GET, [](AsyncWebServerRequest *request){
        struct QueueSmart PinDec;
        int params = request->params();
         for(int i=0;i<params;i++){
           AsyncWebParameter* p = request->getParam(i);
           if(i == 0){
             PinDec.Pin = (p->value().toInt()-1);
           }else if(i == 1){
             PinDec.Address = p->value().toInt();
           }else if(i == 2){
             PinDec.ID = p->value();
           }else if(i == 3){
             PinDec.Timer = p->value().toInt();
           }
         }
        xQueueSend(xQueue, &PinDec, portMAX_DELAY);
        AsyncWebServerResponse *response = request->beginResponse(200, "text/plain", "ok");
        response->addHeader("Access-Control-Allow-Origin","*");
        request->send(response);
});
christian-0s
@christian-0s

Hello, I have a problem with UTF-8 characters in a json response with AsyncWebServer. Using standard WiFiServer of ESP32 Arduino core UTF-8 characters are printed correctly, while the same json string using AsyncWebServer shows garbled characters instead of the correct ones.

cLength = snprintf(json, sizeof(json), "{\"info\":{\"time\":\"%s\",\"ip\":\"%u.%u.%u.%u\",\"devicename\":\"%s\"},\"iostate\":{\"sensor\":[{\"name\":\"Temperatura\",\"number\":0,\"unit\":\"°C\",\"value\":%.1f},{\"name\":\"Umidità\",\"number\":1,\"unit\":\"%%\",\"value\":%.1f},{\"name\":\"Polvere\",\"number\":2,\"unit\":\"n/m³\",\"value\":%.0f}]},\"system\":{\"uptime\":%d}}", reading_time, ip[0], ip[1], ip[2], ip[3], EAP_IDENTITY, t, h, d, up_min);
client.println("HTTP/1.0 200 OK");
client.println("Access-Control-Allow-Origin: *");
client.println("Cache-Control: no-cache,private,max-age=0");
client.println("Content-Type: application/json; charset=utf-8");
client.println("Connection: close");
client.print(F("Content-Length: "));
client.println(cLength);
client.println();
client.println(json);

prints
{"info":{"time":"2020-06-09,06:39:09","ip":"10.227.125.139","devicename":"ESP32_SENS5"},"iostate":{"sensor":[{"name":"Temperatura","number":0,"unit":"°C","value":26.4},{"name":"Umidità","number":1,"unit":"%","value":47.6},{"name":"Polvere","number":2,"unit":"n/m³","value":93186}]},"system":{"uptime":603}}
while

AsyncResponseStream *response = request->beginResponseStream("application/json; charset=utf-8");
response->printf("{\"info\":{\"time\":\"%s\",\"ip\":\"%u.%u.%u.%u\",\"devicename\":\"%s\"},\"iostate\":{\"sensor\":[{\"name\":\"Temperatura\",\"number\":0,\"unit\":\"°C\",\"value\":%.1f},{\"name\":\"Umidità\",\"number\":1,\"unit\":\"%%\",\"value\":%.1f},{\"name\":\"Polvere\",\"number\":2,\"unit\":\"n/m³\",\"value\":%.0f}]},\"system\":{\"uptime\":%d,\"heap\":%d}}", reading_time, ip[0], ip[1], ip[2], ip[3], EAP_IDENTITY, t, h, d, up_min, ESP.getFreeHeap());
request->send(response);

prints
{"info":{"time":"2020-06-09,07:09:58","ip":"10.227.125.132","devicename":"ESP32TEST"},"iostate":{"sensor":[{"name":"Temperatura","number":0,"unit":"�C","value":28.1},{"name":"Umidit�","number":1,"unit":"%","value":42.7},{"name":"Polvere","number":2,"unit":"n/m�","value":82319}]},"system":{"uptime":0,"heap":212032}}
As you can see, characters °, à and ³ are not rendered correctly.
Any idea on what may cause this issue?

Anyone, please?

zekageri
@zekageri
That was my problem with same standard text. Some unicode characters doese not go trought the async sockets. In my case that was a % and some other ones
christian-0s
@christian-0s

That was my problem with same standard text. Some unicode characters doese not go trought the async sockets. In my case that was a % and some other ones

In my case "%" is ok, but "°", "à" and "³" are not

zekageri
@zekageri

That was my problem with same standard text. Some unicode characters doese not go trought the async sockets. In my case that was a % and some other ones > > In my case "%" is ok, but "°", "à" and "³" are not

I managed the spec char problem in the javascript side with this:

var Message = "Some special chars inside like \n and % etc.."; 
encodeURI(Message);

And than send.

The problem that i'am facing now is that i can't send a large message trought GET. I'am trying with multiple params, with one param, but if the message exceeds some limit, the esp does not get anything. I'am trying to write the message to a file. Tried the write iside the GET callback, and tried to write from the main with a flag. ( These are multiple "largeish" json datas )

Chris
@cgreening
Searched through all the previous issues and have opened - #803 - does anyone know if support for HTTPS on the ESP32 is in the pipeline or how difficult it would be to get it working. Really don't want to have to switch to a different library as I'm pretty much done on my current project...
zekageri
@zekageri
I want to know that too. It would be awesome.
Durantis
@Durantis

How can i change:

if (!request->authenticate(http_username2, http_password2))
  return request->requestAuthentication();

For a login html page?

Ruud Boon
@ruudboon
Anybody got an idea how to debug ESPAsyncTCP? After every message I got a disconnect
Christopher
@christopher-merkley
Is it possible to run AsyncWebServer on a single core only? I have a timing sensitive task on the other core, so I don't want this to interrupt it
christian-0s
@christian-0s

That was my problem with same standard text. Some unicode characters doese not go trought the async sockets. In my case that was a % and some other ones

In my case "%" is ok, but "°", "à" and "³" are not

Sending hex code for unicode character is a workaround, for example "\xC2\xB0" instead of "°"

Andreas Merkle
@BlueAndi
@atanisoft Thanks Mike for the link to the FS comparison.
Mike Dunston
@atanisoft
sure, I've been evaluating LittleFS as well for my projects
it works quite well on the ESP32S2 as well
Andreas Merkle
@BlueAndi
I integrated it in one of my projects too for eval. Hopefully platformio will support it till end of this year too. Would make things easier.
Pavel Melnikov
@positron96
Hello guys! Can you please advise me on how to match exact URLs? As I understand, server.on("/a",...) will match "/a", "/a/b", "/a/x/y/z" etc, but I need a separate handler for exact "/a" and separate handler for "/a/..."
lorol
@lorol
If you are using server.serveStatic("/" ... to serve from /data folder in separate partition, you will be similar to web server behavior.
lorol
@lorol
Otherwise, this may be interesting for you, @positron96 : https://github.com/me-no-dev/ESPAsyncWebServer#path-variable
See FILTER
Pavel Melnikov
@positron96
Hm, yes, filter seems to be the way to go. I'd like to not enable regexes for just that one task. Thank you!
zekageri
@zekageri
You need https connection. I would use the service workers too.
TungNT-2810
@TungNT-2810_gitlab
Hello guys, Could I use delay() inside ArRequestHandlerFunction like:
server.on("/discover", HTTP_GET, [](AsyncWebServerRequest *request) {
delay(10000);
request->send(204, F("text/plain"));
};
Mike Dunston
@atanisoft
@TungNT-2810_gitlab using delay inside a handler is not supported.
TungNT-2810
@TungNT-2810_gitlab

@TungNT-2810_gitlab using delay inside a handler is not supported.

Is there a way to extend request timeout for request without using request->client()->setRxTimeout(). I want to query MDNS service with timeout inside request. Thanks!

TungNT-2810
@TungNT-2810_gitlab
I'm using MDNS.queryService() inside handler and it's using delay() for wating for response, I want to extend timeout inside queryService(), is there any chance?
Mike Dunston
@atanisoft
not likely
TungNT-2810
@TungNT-2810_gitlab

not likely

seem i will try holding requests and excuting in loop(). Thank you!

Matias Silva
@matiasilva
hi folks, is there any way to access the FreeRTOS task via a queue handle? I'd like to send messages from one task to the web server task to return in a response.
tomtdl
@tomtdl
Thank you for making the ESP Async libraries. You saved me a ton of work and I learned a lot about servers too ! Good work.