Connection to server failed

I have an Anvil web app being used by a customer 24/7, running on a Raspberry Pi with Chromium in kiosk mode (full-screen).

The app has 3 timers on it. Two of the timers make server calls, one every 30 seconds and the other every 60 seconds. These timers are responsible for refreshing the data that is displayed on the webpage. About once a day the webpage stops updating and shows the error “Connection to server failed”. The App logs point at one or the other of these timer methods in the stack trace.

To date, I have not been able to predict when this error will occur.

At first, I suspected the error was due to the Pi running out of memory so I upgraded to one with 2GB RAM (4x what the previous one had) and began monitoring memory to ensure it doesn’t get too low. Unfortunately, the error still occurs.

Refreshing the browser seems to fix the problem but this is not always feasible for the customer, given how the app is being used.

Some things I am about to try are 1) using a standard URL for the app vs. a hidden link (I doubt it will fix the exception but it will help make sure refreshes don’t cause the “can’t access secret link” redirect) and 2) having crontab-based code refresh the browser and/or reboot the computer a few times a day to try and head-off the problem before it occurs.

#2 feels especially inelegant so I would definitely appreciate any suggestions for other things I can try in order to stop my app from freezing up.

Thanks in advance.

I guess constantly making server calls may cause issues. When doing stress test with my app, I got the same problem while my VPS is extremely huge (64G RAM, 24 cores)

You may use try catch to refresh the app if error occur and use background task to make sure the server is not overloaded

@Tony.Nguyen,

Brilliant that you did stress testing and found that this could be a problem. You probably just saved me hours of problem solving.

I like your suggestion of catching the exception and using a background task for ensuring the server is OK. Is that what you did? Would you be willing to share out small pieces of the code in question so that I could learn from it? Either way, thanks so much for the advice. I am going to try it out.

@matt, here are the links to matters: