Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 24 20:47
    stale[bot] closed #818
  • Oct 24 20:47
    stale[bot] commented #818
  • Oct 24 20:47
    stale[bot] labeled #835
  • Oct 24 20:47
    stale[bot] commented #835
  • Oct 24 05:56
    FrankBoesing closed #868
  • Oct 24 05:56
    FrankBoesing commented #868
  • Oct 23 15:05
    Wummeke edited #869
  • Oct 23 13:43
    Wummeke edited #869
  • Oct 23 13:40
    lorol commented #868
  • Oct 23 13:39
    lorol commented #868
  • Oct 23 13:39
    lorol commented #868
  • Oct 23 13:17
    rikki78 opened #870
  • Oct 23 12:06
    Wummeke opened #869
  • Oct 23 11:27
    FrankBoesing opened #868
  • Oct 23 00:31
    stale[bot] labeled #824
  • Oct 23 00:31
    stale[bot] commented #824
  • Oct 22 07:41
    m2sarmadi opened #867
  • Oct 22 07:36
    m2sarmadi closed #864
  • Oct 22 07:36
    m2sarmadi commented #864
  • Oct 22 03:31
    yngndrw edited #866
Jordan Rubin
@jordancrubin
I noticed there was no release for this, any reason. Im doing a project that is not in platformIO, arduino IDE and cannot find this library in the library search
AndriiNaboka
@AndriiNaboka
Hi! I am using library https://github.com/me-no-dev/ESPAsyncWebServer. Working with web socket esp8266 crashed when i try close live connection with ws.closeAll(). How to close correctly web socket ? I need this on user logout.
Also crashed when ws.enable(false)
AndriiNaboka
@AndriiNaboka
Looks like my bug was.
Michael
@sparkplug23
Correct me if I am wrong, but you can't have a url include a sub version of another. Ie /page and /page/sub both trigger /page
Nicolò Santilio
@fenix-hub
Hi everyone, I'm new with this library. Is it possible to use the wss protocol instead of the ws? In the example I only see the ws protocol used for AsyncWebSockets
lorol
@lorol
I believe, it is not possible as it is. What is the reason you may want wss while https:// is not available out-of-box here neither?
AndriiNaboka
@AndriiNaboka
Hi! Another issue. I have added library https://pubsubclient.knolleary.net/. #include <PubSubClient.h>. And i was surprised. There is no compatibility between them. Libraries works separately, but not together. Maybe somebody knows how PubSubClient library and EspAsynchWebServer lib can work together?
The issue is connection failure to AWS. Without EspAsynchWebServer connection was successful.
lorol
@lorol
EramQuodEs
@EramQuodEs
Hi all! I would like to use just a websocket client on esp32. I have found other solutions but they seem unstable. Is there any example on how to use parts or the whole of EspAsyncServer for this task? To clarify, I have a node javascript websocket server in my office and my esp32 should be able to connect and tranfer high frequency real time measurements via websocket and wifi. With my current solution the esp32 restarts randomly. Any help will be much appreciated.
AndriiNaboka
@AndriiNaboka

@EramQuodEs define web socket in your sketch AsyncWebSocket ws("/device/ws"); define client AsyncWebSocketClient globalClient = NULL;
define void onWsEvent(AsyncWebSocket
server, AsyncWebSocketClient client, AwsEventType type, void arg, uint8_t *data, size_t len){
if(type == WS_EVT_CONNECT){

Serial.println("Websocket client connection received");
globalClient = client;

} else if(type == WS_EVT_DISCONNECT){

Serial.println("Websocket client connection finished");
globalClient = NULL;

}
}

in the loop check if connection established
//check if socket established
 if(globalClient != NULL && globalClient->status() == WS_CONNECTED){

  globalClient->text(doc.as<String>());
}
From client side set up connection
        var uri = 'ws://' + location.host + '/device/ws';
        console.log(uri);
        window.webSocket = new WebSocket(uri);
EramQuodEs
@EramQuodEs
Thanks @AndriiNaboka. I appreciate the proposed solution. But I think I'm looking rather for the opposite. I mean, in your scenario the esp32 is still a server, correct me if I'm wrong. One issue with setting up a server is that I will not be able to know its IP, and so clients will not be able to connect. The esp32 is actually on a car, connecting to internet via a protable wifi/3g modem router with certain port forwarding settings. So I want to avoid to set up a server on esp32 when the clients will have no idea where to connect to. By looking at the code and the examples, I fear that there is no way to use this library solely as a client. My hope is to have several esp32's pushing real time data to one central point via websocket. Thanks again!
Nicolò Santilio
@fenix-hub
@lorol Hi and thanks for your answer. It was just out of curiosity, since I'm making a websocket application and wanted to see if it was also possible to use the wss certificate
lorol
@lorol
@fenix-hub the secure connection for ESPAsyncWebServer needs would be provided by low-level TCP Async. People work on it but still troubles, see for both platforms: me-no-dev/ESPAsyncWebServer#753
me-no-dev/AsyncTCP#90
Michael
@sparkplug23
Hey guys, can someone please point me in the right direction. I am sending json from a webpage to the asyncwebserver with http_post, but I cant seem to get the body/json out from the listener.
I see handlebody in the docs, but not sure how to use it
Michael
@sparkplug23
also, I said json, but it could be anything so I don't want to use the arduinojson example handler
Michael
@sparkplug23
#include "AsyncJson.h"
#include "ArduinoJson.h"

AsyncCallbackJsonWebHandler* handler = new AsyncCallbackJsonWebHandler("/rest/endpoint", [](AsyncWebServerRequest *request, JsonVariant &json) {
  JsonObject& jsonObj = json.as<JsonObject>();
  // ...
});
server.addHandler(handler);
I tried using this.. won't compile. Does async use old json v5?
I see it does.. damn
Andreas Merkle
@BlueAndi
Michael
@sparkplug23
where/how do I use this? @BlueAndi
 pWebServer->on("/save_animation_controls", [this](AsyncWebServerRequest *request){ 
   handleBody(request,...); //like this and pass in a buffer etc?
}
For this as you linked (I seen it earlier too but couldnt understand how to use it)
void handleBody(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){
  if(!index){
    Serial.printf("BodyStart: %u B\n", total);
  }
  for(size_t i=0; i<len; i++){
    Serial.write(data[i]);
  }
  if(index + len == total){
    Serial.printf("BodyEnd: %u B\n", total);
  }
}
Michael
@sparkplug23

  pWebServer->on("/connect", HTTP_POST, [](AsyncWebServerRequest *request) {
       request->send(204);
  }, NULL, handleBody);
I realise this is closer to the answer
Michael
@sparkplug23
If I do this, am I correct in thinking the internal "virtual" handleBody should no longer be called? (it is, and mine added is not)
Andreas Merkle
@BlueAndi
Michael
@sparkplug23
@BlueAndi Thank you!! This has been wrecking my brain for days. Sincere thanks.
dev null
@devnull89191633_twitter
Hey I am using arduino espressif framework and there is a copy of ESPAsyncWebServer library be it up to date or not within it. When my library(WiFiManager Development branch by tzapu) calls server.reset(); it crashes the ESP32 for some reason. Can anyone help me on this?
lorol
@lorol
@devnull89191633_twitter Just copy ESPAsyncWiFiManager.cpp and ESPAsyncWiFiManager.h from this example: https://github.com/lorol/ESPAsyncWebServer/tree/master/examples/SmartSwitch and it should work OK. You can find the original source, too
dev null
@devnull89191633_twitter
@lorol It seems like you've removed stopconfigportal and shutdownconfigportal functions from yours?
Sean Yong
@vjsyong
Hi friends. I'm quite new to web development on the ESP32 platform. I've been using this library and it's been working great so far. However, I want to use the getDeviceOrientation API for javascript. But the caveat is that it's not possible to do so without a secure connection. Is there anyway that I can enable a secure connection with this library?
dev null
@devnull89191633_twitter
Hello, I would love to learn if there is any way to define a timeout period for AsyncUDP's onPacket() method. I don't want it to asynchronously wait until a packet arrives, instead I want it to terminate and garbage collect itself after a timeout period. Is there anyway I can achieve that?
Daniel Brunner
@0xFEEDC0DE64
Hi, do you think it is possible to serve a multi-js webapp through this async webserver (from SPIFFS)
The webapp seems to be some compiled ionic shit, which uses about 10 js files, and when served through the esp, lots of requests just hang
some js downlaods in the browser have download times like 40secs and more
and some just result in failed
image.png
image.png
E (53613) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (53613) task_wdt:  - async_tcp (CPU 0/1)
E (53613) task_wdt: Tasks currently running:
E (53613) task_wdt: CPU 0: IDLE0
E (53613) task_wdt: CPU 1: IDLE1
E (53613) task_wdt: Aborting.
abort() was called at PC 0x40108c6c on core 0

Backtrace: 0x4008f608:0x3ffbe170 0x4008f839:0x3ffbe190 0x40108c6c:0x3ffbe1b0 0x400869c9:0x3ffbe1d0 0x4019e1e3:0x3ffbc3b0 0x4010a1ca:0x3ffbc3d0 0x4008d511:0x3ffbc3f0 0x4008bd1d:0x3ffbc410

Rebooting...
lots of reboots while loading the page
lorol
@lorol
You can try to consolidate all js files to one, minimize and gzip them, same with css. In my case this worked fine. If scripts are standalone and don’t require Intrenet
It may work for you
sillyfrog
@sillyfrog
@0xFEEDC0DE64 FYI: all you need to do to gzip them is to run gzip on each file, and leave the .gz extension, the SPIFFS module in the ESPAsyncWebServer will take care of the rest.
I have found a similar issue with serving many files at once, and the best solution for me was to make it all one mega file, and then gzip it when I was happy with everything. I have zero issues, without compression, with this 92KB file: https://github.com/sillyfrog/PrettyLights2/blob/master/data/index.htm
If you look at the JS in that file you will see that I have gone to great lengths to have it "single threaded" - ie: only upload and download one file at a time so not to overwhelm the ESP8266. The number of requests appears to be the issue, not the size in my experience.
Daniel Brunner
@0xFEEDC0DE64
@sillyfrog thx for the response, it works :)
Eddy Maue
@eddymaue_twitter
no match for call to '(AsyncWebServer) (uint16_t&)'
Eddy Maue
@eddymaue_twitter

/*
C++ File >> emESPAsyncWebServer.h
**/

ifndef _emESPAsyncWbSrvr_H

define _emESPAsyncWbSrvr_H

//----------------------------------------------------------------------------------------------------

include "Arduino.h"

include <ESPAsyncWebServer.h>

include "Perso.h"

include <string.h>

//class EmESPAsyncWbSrvr : public AsyncWebServer
class EmESPAsyncWbSrvr : public AsyncWebServer
{
private:
//AsyncWebServer m_server;
AsyncWebServer m_server;

int m_iPort = 80;

String m_IP = "---.---.---.---"; //

public:
//AsyncWebServer s; //server

EmESPAsyncWbSrvr(int iPort);

void Begin(void);

/// friend AsyncWebServer;
};

endif

/*
C++ File >> emESPAsyncWebServer.cpp
**/

include "emESPAsyncWebServer.h"

EmESPAsyncWbSrvr::EmESPAsyncWbSrvr(int iPort)
{
m_iPort = iPort ;

uint16_t iz=0;
int i = 0;

//i dont able to convert int into uint_16
// so i use for(;;)
for ( i=0 ; i<iPort+1 ; i++)
{
iz++;
}

/*
I use platformIO
This is my main problem and I have 2 errors
1) call of an object of a type of class without appropriate operator () or functions of conversions in type pointer to function
2) no match for the call to '(AsyncWebServer) (uint16_t &)'

I'm trying to implement ESPAsyncWebServer.h in a class and it crashes ... that, alas, I wonder if it's possible

I also added AsyncWebServer () as constructor in the AsyncWebserver.h class
*/
m_server(iz);

WiFi.begin(SSID, PASSWORD);
Serial.print("Tentative de connexion...");
i = 0;
while (WiFi.status() != WL_CONNECTED)
{
    i++;
    Serial.print(".");
    delay(100);
    /*----------------------------------redémarrage de l'esp32 apres 10 tentative*/
    if (i > 10)
    {
        ESP.restart();
    }
}
Serial.println("\n");
Serial.println("Connexion etablie!");
Serial.print("Adresse IP: ");
Serial.println(WiFi.localIP());

}

void EmESPAsyncWbSrvr::Begin()
{
m_server.begin();

}

/*
C++ File >> emESPAsyncWebServer.h
**/

ifndef _emESPAsyncWbSrvr_H

define _emESPAsyncWbSrvr_H

//----------------------------------------------------------------------------------------------------

include "Arduino.h"

include <ESPAsyncWebServer.h>

include "Perso.h"

//class EmESPAsyncWbSrvr : public AsyncWebServer
class EmESPAsyncWbSrvr : public AsyncWebServer
{
private:
AsyncWebServer m_server;

int m_iPort = 80;

String m_IP = "---.---.---.---"; //

public:

EmESPAsyncWbSrvr(int iPort);

void Begin(void);

/// friend AsyncWebServer;
};

endif