popup-chat icon indicating copy to clipboard operation
popup-chat copied to clipboard

Locks up once messages string gets too long.

Open Prosthet1cHead opened this issue 6 years ago • 4 comments

I've been playing with this useful little project. I've noticed that, although it says only the last few messages are displayed, the system as it is simply accumulates messages and once a certain length of string for the total messages is reached the web server simply stops responding. As such, it becomes useless unless rebooted, erasing all messages, frequently enough that it never gets a chance to fill up.

Presumably the desired behaviour would be that as the limit is approached the oldest messages are removed to make space for new messages? This would allow it to run indefinitely and unattended, and also prevent from having to erase all messages at once with a reboot to keep it working.

Any idea what the limit is or how to implement this? I may have a go myself, but I'm far from an expert in Arduino programming for this chip.

Prosthet1cHead avatar Aug 02 '18 09:08 Prosthet1cHead

I've been having a go at this, but I'm not much an expert at programming these devices. Can anyone help? As the memory gets full it would be good to automatically discard the oldest messages rather than have the device become unresponsive until rebooted.

Prosthet1cHead avatar Jan 22 '19 15:01 Prosthet1cHead

Hey there,

The problem is that the data storage that is used is just a string that keeps getting longer and longer, as you noticed. Worse still, it's HTML.

The problem with simply chopping the string in half is that we might be in the middle of an HTML tag, which would have deleterious effects on the user interface.

I haven't been dabbling with the ESP platform too much lately and even then it has been mostly ESP32 which makes it tough to update this project.

I'm pondering an easy fix. What board are you using so I can estimate sizes? Tell me more about your use case, I'm eager to hear about someone finding this old project! :)

tlack avatar Jan 22 '19 22:01 tlack

Hi, I'm dabbling with a variety of ESP boards, including a bunch of cheap little ESP-01s I've built in to 2xAA battery boxes with a switch, powered with a single AA sized LiFePO4 cell (3.6 - 3.0V operating range). The result is very small, robust and should be durable too, since the LiFePO4 cells degrade far slower than other lithium chemistries. I'll upload a picture if you're interested, but it's really simple. With your project these make very nice little popup chat hotspots for taking on group trips, camping, festivals & events I attend. I also find it an intriguing social experiment just to walk around town doing my shopping with one in my pocket (seen everything from basic chat, detailed political statements, expletives & asking when the next bus is due).

If it can be made to manage the memory and thus achieve longer uptime unsupervised it would also be useful to provide some short information and a chatroom for more permanent venues & events.

I'm in the process of making a solar charged LiFePO4 battery / ESP8266 system that I can set up, waterproof and then place in somewhere to hopefully run totally unsupervised for an extended period for various applications, one of which could be popup chat, if it were able to run unsupervised indefinitely.

As for the board I'm using, the most limited must be the ESP-01 module, but obviously a variety will be used both by myself and potentially other users, perhaps we can define module memory at the top of the file?

Could it work to have each message as a separate string and discard the oldest ones as necessary to leave adequate memory as new messages are added?

Thanks very much for your reply & for sharing the project, I wish I had the skills to implement a fix myself but I'm pretty new to anything that isn't simple python scripts...

All the best!

Prosthet1cHead avatar Jan 23 '19 16:01 Prosthet1cHead

Hi All. Looking for a simple BBS/local chat I found your project, amongst another one. The following one uses SPIFF storage for the messages, which might help with the lockdown: https://devcraze.com/tutorials/internet-of-things/create-awesome-wifi-chat-with-captive-portal-using-nodemcu-esp8266/

Another thing to consider is to store messages in a clients' localstorage (cookie) and pull/push them to the server as I once implemented in a project (https://github.com/jngrt/meshenger/tree/master/web). Also a tip for images: base64 encoding ;)

Good luck! Will post when I made someting (aka lofi port of https://github.com/jngrt/meshenger/) to esp8622....

dennisdebel avatar Feb 26 '20 18:02 dennisdebel