Giter Site home page Giter Site logo

Comments (26)

ahmadmn avatar ahmadmn commented on June 23, 2024

I see similiar problem of kosmonavtX in your example:
https://gist.github.com/me-no-dev/116e417ea6a3bbc98b08
Thanks

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

can you guys please post some code that I can have a look at. the lib is asynchronous which means that if you do not waste time in the callbacks, there is no way for it to cause wdt. All calls return immediately and process the data in background.

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

@ahmadmn client should be set to NULL here

from espasyncwebserver.

ahmadmn avatar ahmadmn commented on June 23, 2024

Thanks a lot
Now it works perfectly!

from espasyncwebserver.

cosmoiler avatar cosmoiler commented on June 23, 2024

@me-no-dev, code is large enough.
I'm using a different library. In the synchronous and asynchronous mode runs without resetting. Code function event from websocket almost the same:

  1. with wdt reset
  2. without reset, library arduinoWebSockets

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

@kosmonavtX interesting.. the code looks fine. How should I run it to trigger the error?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

when you say disconnect, do you mean that you run through the disconnect routine, or that the browser closes, or how?

from espasyncwebserver.

cosmoiler avatar cosmoiler commented on June 23, 2024

Wdt reset when the page is refreshed, the client is disconnected.
For web pages I use your async server. But wdt reset came only when connected websockets. Prior to this, all worked well.

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

what browser are you using? I used to see those problems sometimes with chrome but I believe I fixed them

from espasyncwebserver.

cosmoiler avatar cosmoiler commented on June 23, 2024

Most firefox. Less chrome.

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

cool, will give it a go and see what the results will be.

from espasyncwebserver.

pabjr avatar pabjr commented on June 23, 2024

So I was having the same problem and tracked it down to this piece of code.

If I comment out this line, all works well.

I am unsure what other ramifications this has but I imagine that it is meant to free memory after the socket closes. I suspect that the 'cl' would pass out of scope anyway and the delete is not needed. But, there is a high probability that I am wrong.

Also, I don't know if the line above it does anything at all. The function it calls just returns a bool.

Hope this helps, BTW ... This is a great little piece of code me-no-dev.

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

this is interesting... the line you talk about just frees the client from the memory. Are there any stack traces coming out? onDisconnect should be actually the very last piece of code that get's executed before the connection is totally closed, so why would it error? Btw I have tested this extensively with Chrome and Safari (mac user here) and did find differences in how they handle disconnects, but got to fix all of that.
@pabjr if you remove that line, there should be a mem leak. Can you confirm that?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

ok I think I might have a pointer to what could be going wrong (maybe).
Try to remove the very next line server->handleDisconnect(this); and replace it with delete this;
could be the fact that the web server is expecting to clear a request object, instead of WebSocket

from espasyncwebserver.

cosmoiler avatar cosmoiler commented on June 23, 2024
ws[/ws][1] disconnect: 0
hDisconnect2
_client->onDisconnect

 ets Jan  8 2013,rst cause:4, boot mode:(3,1)

wdt reset

_server->_handleDisconnect(this):

void AsyncWebSocket::_handleDisconnect(AsyncWebSocketClient * client){
  if(_clients == NULL){
    return;
  }
  if(_clients->id() == client->id()){
    _clients = client->next;
    delete client;

    Serial.println("hDisconnect2");

    return;
  }
  AsyncWebSocketClient * c = _clients;
  while(c->next != NULL && c->next->id() != client->id()) c = c->next;
  if(c->next == NULL){
    return;
  }
  c->next = client->next;
  delete client;
}

Maybe somewhere here?

_client->onDisconnect([](void *r, AsyncClient* c){ ((AsyncWebSocketClient*)(r))->_onDisconnect(); Serial.println("_client->onDisconnect"); }, this);

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

hmmm... that's not it... if you see _client->onDisconnect printed to serial, that means that the free went fine. your boot mode also looks funky? boot mode:(3,1) I wonder why 3,1?
do you see a delay between the last print and the wdt triggering?

from espasyncwebserver.

pabjr avatar pabjr commented on June 23, 2024

O.K. a little update...

Yes, my last edit caused a mem leak but I traced the problem a little further and have isolated it to the following code

If I comment out:

if(err != ERR_OK) { err = abort(); }

everything works as written and there is no mem leak as far as I can tell.

To this point I have not been able to understand why it does not look like the PCB is closed or why the abort statement causes a reset.

Any thoughts?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

I scratched my head quite some time today also. I could not find a way to reproduce it constantly though... I had chrome and firefox both open refreshing, reconnecting and whatnot and every now and then I'll get wdt or funky exception on connect. Saw some strange packets coming from chrome about already closed connections. I saw chrome to ack one less byte (maybe some sort of keep alive), but nothing that can get me a clue at what point exactly the code breaks.
I'll read the source for close and what are the possible scenarios of return.
Can you put debug there and note whet is the error code that triggers it on your end?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

ok... if you replace this line with client->close(true); it should fix your problem, though it opens another one... for some reason the connection is kept in wait state for another minute till it's released, so if you have something going connect -> disconnect ->.... you will at some point run out of heap (given connect/disconnects happen one after another) which is not cool...

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

guys, this is fixed! Please update your TCP libs as well and give it a go!

from espasyncwebserver.

pabjr avatar pabjr commented on June 23, 2024

me-no-dev ... works great. I can not repeat the reset.

Thanks for the effort, sorry I could not have been more help.

Quick question, you said the fix opened another problem. Did you solve that one as well?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

Yes i did :) all should be good now :) there are some new features you might like. You can check the readme for more info

from espasyncwebserver.

ahmadmn avatar ahmadmn commented on June 23, 2024

What is application of FSBrowser?

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024

it lets you browse, edit, download and delete contents from SPIFFS through the browser.
Upload the example to your ESP, Upload SPIFFS using the tool for Arduino IDE and you will get it if you try to open http://esp-ip/edit

from espasyncwebserver.

ahmadmn avatar ahmadmn commented on June 23, 2024

Thanks a lot,
1- Is there any tutorial or document for FSBrowser usage?
2- Is "Uploading SPIFFS using the tool for Arduino IDE" as follow: https://github.com/esp8266/Arduino/blob/master/doc/filesystem.md#uploading-files-to-file-system
3- Is FSBrowser useful for my costumers to upgrade firmware(sketch)?
Regards

from espasyncwebserver.

me-no-dev avatar me-no-dev commented on June 23, 2024
  1. No, you do not need one :) open your browser and it's self explanatory.
  2. Yes
  3. No

this is what it looks like:

screen shot 2016-07-01 at 3 26 10

from espasyncwebserver.

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.