Recently I have been getting quite a few “AppOfflineError: Connection to server failed (1006)” errors in development of my apps, and now users are also reporting this error across multiple different apps where I haven’t changed any code.
I see quite a few questions on the forum about this particular error with the consensus that it is an issue on the anvil server side, is there any information about why this error is occurring more and more?
Is there anything I can do to stop these errors reaching my users?
You can add something like this to your startup code (assuming you haven’t already set up custom error handling, in which case you’d need to modify that code):
if isinstance(err, anvil.server.AppOfflineError):
Notification("Server connection error. If something is not working as expected, please refresh the page.",
No easy way that I know of. Yeah, I guess AppOfflineError generally won’t be recorded in the app logs, now that I think of it, because that’s an error that occurs on the client-side and means that it can’t contact the Anvil server (including to register to event in the logs). It is the error that is triggered when the client device loses its connection to the internet, but I do think it can also be triggered if the internet connection is fine in general but the Anvil servers are unavailable in particular.
If you’re troubleshooting it live with someone, you can ask whether the internet is working for other websites, and you can check whether the Anvil servers are working otherwise. But I’m not sure if there’s a way to sort out a past event in retrospect, other than checking the forum to see if others reported an Anvil outage.
update: This clever new feature request might make it possible to see some such errors in app logs:
Thanks, this makes sense. Agreed the feature request would be helpful and I’ve ‘liked’ it.
I am just trying to work out if the notable increase in users reporting AppOffline errors is to do with users own connection or an anvil side problem. For now I will assume users, and get them to check their connections and see if the problem continues.