Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 06:21
    altelch synchronize #6865
  • 05:05
    earlephilhower opened #6896
  • 04:19
    devyte milestoned #6895
  • 04:19
    devyte demilestoned #6895
  • 03:42
    devyte synchronize #6881
  • 03:42
    devyte demilestoned #6881
  • 03:42
    devyte milestoned #6881
  • 02:05

    devyte on master

    Use 128B chunks instead of 1B w… (compare)

  • 02:04
    devyte closed #6893
  • 02:04
    devyte closed #6524
  • 01:09
    d-a-v closed #6718
  • 01:02
    d-a-v edited #6895
  • 01:00
    d-a-v milestoned #6895
  • 01:00
    d-a-v opened #6895
  • 00:18
    Tech-TX synchronize #6894
  • 00:02
    earlephilhower milestoned #6894
  • 00:01
    earlephilhower synchronize #6566
  • Dec 09 23:57
    Tech-TX edited #6894
  • Dec 09 23:55
    Tech-TX opened #6894
  • Dec 09 23:45
Me No Dev
@me-no-dev
@matasondrak first it’s my Async :D and then it does not leak ;) if it leaks, the issue would be in your code. I am open to be proven wrong though (on the leak)
oh and Igor is actually Ivan :P
dragon-engineer
@dragon-engineer
@me-no-dev thanks for the reply :smile: and for the info
I'll test only with one handler in the entire sketch
Me No Dev
@me-no-dev
async runs pretty low in lwip, so if an SDK update broke or introduced a change that could lead to leak, that is one possibility, but then that leak will be visible in the regular client/servers as well
dragon-engineer
@dragon-engineer
alright, I'm at work and I forgot the nodemcu module home so I'll test later.. but the fact that sdk update increased dramatically size of the sketch is a bit disturbing
Clemens Kirchgatterer
@everslick
@matasondrak the leaks you are seeing are probably sockets held in FIN_WAIT state. they get cleaned up after some time (minutes). the newer SDK limits the number of sockets in FIN_WAIT to something like 5 so the effect is less noticable.
dragon-engineer
@dragon-engineer

I found out what was the cause of the leaks.. it was this NotFound handler:

server.onNotFound({
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/404.html");
response->setCode(404);

even if it was not written correctly, this code shouldn't normally run until I request a file that is not found on the server, right? I found it strange that with this code the sketch has memory leaks, even though I only refresh page /test.html

Me No Dev
@me-no-dev
you refresh /test.html but your browser also requests the little image that can show up in the title bar and since you do not request->send(response); you leak
dragon-engineer
@dragon-engineer
yes the favicon!! I forgot it! good point
Me No Dev
@me-no-dev
in any way and in any handler you should always respond to each request in some way
dragon-engineer
@dragon-engineer
yes definitely, that NotFound handler was your suggestion btw :smile: I asked you how to serve a SPIFFS static file in a custom handler and you sent me this, it worked so I didn't try it for stability/memory leaks
Me No Dev
@me-no-dev
never my idea not to actually request->send(response) ;)
dragon-engineer
@dragon-engineer
that's not it
Me No Dev
@me-no-dev
what is not it?
dragon-engineer
@dragon-engineer
ah sorry you are right, it's the ending of AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/404.html");
so what's better way? I asked here and got this solution suggested...
Me No Dev
@me-no-dev
server.onNotFound([](AsyncWebRequest * request){
  AsyncWebServerResponse *response = request->beginResponse(SPIFFS, "/404.html");
  response->setCode(404);
  request->send(response); //<<<very important line of code ;)
}
oops
dragon-engineer
@dragon-engineer
It's there.. I wrote it for the first time and then just omitted it
the problematic handler looks exactly like yours :smile:
Me No Dev
@me-no-dev
then it should not leak… I do not get it...
dragon-engineer
@dragon-engineer
yes, that's why I didn't test it earlier, nothing suspicious around
when I use request->send(404, "text/html", "404 Not Found"); it's all good
Me No Dev
@me-no-dev
what id you just request->send(SPIFFS, "/404.html”);
dragon-engineer
@dragon-engineer
unfortunately I didn't take my ESP module to work again :clap: so I can either send you a zipped solution with html or I'll do it myself in the evening
Me No Dev
@me-no-dev
you do have “/404.html”in the file system right?
dragon-engineer
@dragon-engineer
yes :smile:
Me No Dev
@me-no-dev
please do try tonight
dragon-engineer
@dragon-engineer
it serves the file but leaks
ok I will do the test
Me No Dev
@me-no-dev
how big is that file?
dragon-engineer
@dragon-engineer
like 3kB
Me No Dev
@me-no-dev
hmmm then it’s not the SPIFFS bug we have been having...
dragon-engineer
@dragon-engineer
when serving large files?
Me No Dev
@me-no-dev
yes
dragon-engineer
@dragon-engineer
yes I wouldn't expect/torture the ESP with megabytes of files
Me No Dev
@me-no-dev
30K is enough to trigger it :)
dragon-engineer
@dragon-engineer
oh :smile: a different story then
however, I used to been using gzip compression in my project, and when I just updated SDK to the latest, it's all buggy
*have been, damn
I used this scheme: in SPIFFS just GZipped files, delete normal .css/.js . in the SPIFFS static file handlers was normal .js and path to SPIFFS file .js
this worked like charm until I updated
now it sends garbage (plain gzipped text, without decompressing in the browser)
Me No Dev
@me-no-dev
it still might be connected to the same issue. Does the file editor open fine?
if gzip has errors it would not be recognized and decompressed so it will spit crap
dragon-engineer
@dragon-engineer
I haven't try the editor actually..but will do tonight
Me No Dev
@me-no-dev
editor runs from flash and is gzipped
not SPIFFS ;)
dragon-engineer
@dragon-engineer
I thought the memory might have been corrupted somehow so I even tried another NodeMcu module but with the same result. Then I changed the SPIFFS static handler so that it points to the file .js.gz in the filesystem, then it works a little better, no garbage, but it's a 48kB file and two characters in the javascript are wrong.. instead of quotes there is | character, therefor the script won't work.