immich-app / immich

High performance self-hosted photo and video management solution.
https://immich.app
GNU Affero General Public License v3.0
39.48k stars 1.87k forks source link

Mobile app (Android) still shows login screen when server unreachable, even after #7383 #7506

Open bdr99 opened 4 months ago

bdr99 commented 4 months ago

The bug

Similarly to the user in https://github.com/immich-app/immich/issues/4850, I'm using Immich behind a VPN (Tailscale). When the phone is not connected to the VPN, the server will be unreachable. This is causing the app to redirect me back to the login screen, and I am unable to browse my photos offline. The fix in https://github.com/immich-app/immich/pull/7383 unfortunately did not work for me.

I'm using Immich behind a Caddy reverse proxy. The reverse proxy is configured to only allow requests to the Immich server if they originate from the internal network (VPN). When the reverse proxy receives a request from the public internet, it will close the connection and not forward the request to the Immich server.

I'm attaching a CSV log below, but it doesn't contain much info. In addition to the info in the CSV log, the in-app log viewer shows the following details.

From: SplashScreenPage
Message: Failed to resolve endpoint
Details: Connection closed before full header was received

Please let me know if there is any more info I can provide to help troubleshoot this issue.

Immich_log_2024-02-28T141937.253411.csv

The OS that Immich Server is running on

Unraid 6.12.8

Version of Immich Server

v1.96.0

Version of Immich Mobile App

v1.96.0

Platform with the issue

Your docker-compose.yml content

N/A - not using docker compose. Instead, I manually created the Docker containers in Unraid, using the docker-compose.yml from the repo as a guide.

Your .env content

N/A - using Unraid.

Reproduction steps

1. On the phone, disconnect from the Tailscale VPN.
2. Force stop the Immich app.
3. Open the Immich app.

Expected behavior: App should open in offline mode and should be able to browse photos.
Actual behavior: Redirected back to the login screen.

Additional information

No response

t18n commented 4 months ago

I am experiencing the same issue on iOS app 1.91.0 build 141 - server 1.97.0. In my case, it was not due to VPN disconnection but when my server is down.

f-x1-1 commented 4 months ago

There should be an offline mode or something that would prevent Immich from returning to the login screen when your server is offline or, in your case, using Tailscale.

Tushar-Harsora commented 4 months ago

@f-x1-1 Can you tell what response you get when visiting https://{YOUR_HOSTNAME}/.well-known/immich while you are not on tailscale. if you get 502 Bad Gateway then I have a possible fix.

FIX is: In mobile/lib/shared/services/api.service.dart:101 we are ignoring any HTTP error codes we also need to return false if we get 502 from server. right now we are returning true.

I can check if this fix works, I have to setup flutter dev environment and find android device to test.

bdr99 commented 4 months ago

@Tushar-Harsora In my case, my web server is configured such that when it receives a request that isn't from Tailscale, it immediately closes the connection. So there won't be a 502 status code, or any status code at all for that matter.

In case it helps, here is the output I get from curl when I send a request from outside my Tailscale network:

$ curl "https://immich.mydomain.com/.well-known/immich"
curl: (92) HTTP/2 stream 0 was not closed cleanly: INTERNAL_ERROR (err 2)
Armaldio commented 3 months ago

Same for me, behind a Cloudflare tunnel

curl "https://xxx/.well-known/immich"
error code: 1033
maxdd commented 2 months ago

Hello, facing the same issue on android app. Currently im hosting locally via docker and have yet to decide whether i want to expose it. The app routes me back to the Server Endpoint URL when using mobile data for example.

This is, at least for me, breaking the possibility to use it as a daily driver, which is bad because the product is great.

Wouldn't it be better for the app to handle remote communication in a side thread with "disabled" features when offline? e.g. connection is not mandatory for the "local" gallery visualization.