icefields / Power-Ampache-2

second version of my popular ampache Android app
GNU General Public License v3.0
47 stars 2 forks source link

Handle 404 server responses graciously #57

Open BlueNalgene opened 4 months ago

BlueNalgene commented 4 months ago

If Power Ampache 2 is logged in to a server which experiences major changes (I deleted the test server), it gets stuck in a 404 loop when interacting with the app again.

Steps to recreate:

Results in:

``HTTP 404 Not Found'' errors several times per second. The logs are full of spam like:

2024-02-23 11:07:21
HTTP 404 Not Found

2024-02-23 11:07:21
getAlbumsStats() - cannot load data HttpException retrofit2.HttpException: HTTP 404 Not Found

2024-02-23 11:07:21
HTTP 404 Not Found

2024-02-23 11:07:21
getAlbumsStats() - cannot load data HttpException retrofit2.HttpException: HTTP 404 Not Found

and so on.

What does not work to fix:

What should happen:

The app should have a way to gracefully exit after a 404 loop is encountered. Logout attempts which result in 404 should result in a single error before stopping the logout process.

Quick Fix for Users

Remove and re-install the app.

icefields commented 4 months ago

thanks for reporting. I don't think the problem is with the server experiencing major changes, from what I see from the logs, there is an issue connecting, that I think would happen regardless of the server changes (would happen every time the app cannot connect to server, regardless of the updates on the backend). I also suspect that's not a loop, but instead a finite number of calls that fail every time (but I need to look into this to confirm). When a user re-enters the app there is an attempt to refresh all the data, that triggers at least 8 calls (session call, user info, recent albums, newest, most played, favourites, etc...), which in your case are all failing because there is an issue connecting to the server. The big numbers of calls failing might make it look like a loop. Anyway, the app should definitely handle server errors graciously. I'm going to look into this.