asjdf / WebSerialLite

Super lightweight remote serial monitor for ESP8266 & ESP32 (frontend <3k)
GNU General Public License v3.0
59 stars 12 forks source link

many calls of WebSerial.println in a row causes problems #11

Open peff74 opened 1 year ago

peff74 commented 1 year ago

Hi, Brilliant libary!

I had big problems with stuttering output at the beginning. Especially when many WebSerial.println came in a row in the skipt:

WebSerial.print ("Measurement_count: ); WebSerial.println (Measurement_count); WebSerial.print ("Unix-Time: "); WebSerial.println (now); WebSerial.print ("Records in cache: ); WebSerial.println (queue.size());

After replacing this with the following, it worked better:

snprintf(printbuffer, sizeof(printbuffer), "Measurement_count: %i \nUnix-Time: %ld \nRecords in cache: %i", Measurement_count, now, queue.size()); WebSerial.println(printbuffer);

Also, I think it is very important to make an adjustment to the AsyncTCP: https://github.com/me-no-dev/AsyncTCP/issues/121 Without this change it kept crashing every few hours.

asjdf commented 1 year ago

Thank you for using this library. I thought you meet the same problem mentioned in #4

Did the FAQ solve your problem? I currently think that in order to ensure the lightweight of the library, the function of caching messages should be implemented by AsyncWebSocket, because WebSerialLite cannot know whether the message queue in AsyncWebSocket has been emptied.

peff74 commented 1 year ago

There is a german proverb: "Those who can read are at a clear advantage!" Of course, I have not watched the FAQ...

I currently used this version of the AsyncWebserver: https://github.com/yubox-node-org/ESPAsyncWebServer/tree/yuboxfixes-0xFEEDC0DE64-cleanup.

Because these are used at e.g. here: https://github.com/tbnobody/OpenDTU https://github.com/lumapu/ahoy Both projects have a serial monitor as a web page

Is the ESPAsyncWebServer from ESPHome better?

I have now increased the WS_MAX_QUEUED_MESSAGES to 32. Which value is useful here, if 3-4 WebSerial.println are run per second?

What is about the menetoried "issue" int the AsyncTCP is this somehow related?

asjdf commented 1 year ago

ESPHome/ESPAsyncWebServer seems to be updating a bit more aggressively, so I was using ESPHome/ESPAsyncWebServer, and so that I submitted a PR to it, but the original version is actually ok, you can make a PR to the original version if you like.

Actually I don't know which value of WS_MAX_QUEUED_MESSAGES if suitable for you, you'd better make some tests by yourselves. Sorry for can't help you. 😟

If you want to solve the issue about "many calls of WebSerial.println in a row causes problems", I thought change the WS_MAX_QUEUED_MESSAGES is enough. If you want to solve the issue https://github.com/me-no-dev/AsyncTCP/issues/121 , I thought you can try to use https://github.com/yubox-node-org/AsyncTCPSock

asjdf commented 1 year ago

I thought the ESPAsyncWebServer you are using is cool! There are a lot of new features! I like it.

peff74 commented 1 year ago

The issue "many calls of WebSerial.println in a row causes problems" is fixed with changing value of WS_MAX_QUEUED_MESSAGES. Perfect :-)

The other problem I pointed on I've already fixed by editing the AsyncTCP.cpp as described in https://github.com/me-no-dev/AsyncTCP/issues/121. I only want to let you know about this, because with the original lib the ESP crashes frequently.

But now I'll try out our suggestion, it seems completely rewritten.

asjdf commented 1 year ago

Thanks for the report, I think the problem has been solved. Can I close this issue and mark it as resolved?

peff74 commented 1 year ago

I have one more question, but I am not sure if it is related to your library. But it occurs only in combination with your library.

What happens is this. If I run the tab with your serial monitor and then open up another tab e.g. google in the browser for some time (10-15 minutes), and then get back to the Serial Monitor page it turns completely blank. Reloading does not work either. After a while, a message appears that the website is no longer responding. Only the complete closing of the tab and reopening works again.

asjdf commented 1 year ago

The problem you meet looks like issue #10 , but I can't reproduce the bug mentioned in #10, I will try to reproduce at this weekend. I am glad if you can help me to solve this bug.

peff74 commented 1 year ago

Hi,

I'm not sure if it's the same error. Because with me there are partly 6000 lines in your tool.

But I can gladly test it. Also, ESP crashes every now and then since your library has been in use. At the moment I have https://github.com/yubox-node-org/AsyncTCPSock https://github.com/yubox-node-org/ESPAsyncWebServer/tree/yuboxfixes-0xFEEDC0DE64-cleanup in use.