immich
immich copied to clipboard
Immich iOS keeps logging out after a day or so
The bug
I recently switched from exposing a port on my network to using Cloudflare tunnels to access Immich over the web. Works great, however I’ve noticed that I keep getting logged out after some time.
Sometimes it’s a day, other times a couple. Seems to be when I’m off local internet for some time. I read that some network resiliency was added a while back but not sure if it’s entirely functional. Cloudflare tunnel doesn’t report to be unreachable at any given time.
The OS that Immich Server is running on
unRAID 6.12 - Docker
Version of Immich Server
1.98.1
Version of Immich Mobile App
1.99.0 b 145
Platform with the issue
- [ ] Server
- [ ] Web
- [X] Mobile
Your docker-compose.yml content
version: "3.8"
services:
immich-server:
container_name: immich_server
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
command: [ "start.sh", "immich" ]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
ports:
- 2283:3001
env_file:
- .env
depends_on:
- redis
- database
restart: always
immich-microservices:
container_name: immich_microservices
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
# extends:
# file: hwaccel.yml
# service: hwaccel
command: [ "start.sh", "microservices" ]
volumes:
- ${UPLOAD_LOCATION}:/usr/src/app/upload
env_file:
- .env
depends_on:
- redis
- database
restart: always
immich-machine-learning:
container_name: immich_machine_learning
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
volumes:
- model-cache:/cache
env_file:
- .env
restart: always
redis:
container_name: immich_redis
image: redis:6.2-alpine@sha256:70a7a5b641117670beae0d80658430853896b5ef269ccf00d1827427e3263fa3
restart: always
database:
container_name: immich_postgres
image: registry.hub.docker.com/tensorchord/pgvecto-rs:pg14-v0.2.0@sha256:90724186f0a3517cf6914295b5ab410db9ce23190a2d9d0b9dd6463e3fa298f0
env_file:
- .env
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
POSTGRES_USER: ${DB_USERNAME}
POSTGRES_DB: ${DB_DATABASE_NAME}
volumes:
- pgdata:/var/lib/postgresql/data
restart: always
volumes:
pgdata:
model-cache:
tsdata:
Your .env content
# You can find documentation for all the supported env variables at https://immich.app/docs/install/environment-variables
# The location where your uploaded files are stored
UPLOAD_LOCATION=./immich-data
# The Immich version to use. You can pin this to a specific version like "v1.71.0"
IMMICH_VERSION=release
# Connection secrets for postgres and typesense. You should change these to random passwords
TYPESENSE_API_KEY=key
DB_PASSWORD=passwordb
# The values below this line do not need to be changed
###################################################################################
DB_HOSTNAME=immich_postgres
DB_USERNAME=username
DB_DATABASE_NAME=dbname
REDIS_HOSTNAME=immich_redis
Reproduction steps
1. Login at home
2. Works fine for some time
3. Come back randomly a few days later and I’m logged out. Rest of family also is
...
Additional information
No response
Do you think CF was playing a part in this? In my prod setup, I use VPN and never get logged out
I don't think so. Cloudflare doesn't report any downtime in the dashboard, and all my other services seem to work fine with no downtime reported. I've installed Uptime Kuma just in case.
But I think this has to do with connectivity between mobile devices and server for some time, maybe in a no service area etc and it gives up on reconnecting
FWIW i've updated to 1.99.0 now. In case the app difference was causing an issue.
Do you have background backup enabled? Maybe we haven't handled that case gracefully
I do indeed have background backup enabled. Can’t trust myself to do timely backups 😂
Thank you, I think it might be the cause. Let me see if I can handle the case it cannot connect to the server gracefully
Sounds good. Let me know if I can provide any additional information or logs
I'm still having this issue with 1.99.0. I am running Immich behind Nginx (publically accessible). No VPN or CF tunnels. Happy to provide logs if helpful.
@mmomjian Do you also use background backup as well?
Yes, I do @alextran1502
Sorry for the bump but do we have any update on this? It is really hurting the wife-approval factor :/ Happy to provide any logs. It happens about 3-4 times / week, when it happens I get a cannot set success login info followed by logout failed for <username> in the app logs.
I am not using tailscale or anything like that. so I don't anticipate that the server is actually unreachable for any reason. The first error seen reads as below:
Cannot set success login info
FormatException: Unexpected character (at character 1)
<!doctype html>
^
From: SplashScreenPage
#0 _ChunkedJsonParser.fail (dart:convert-patch/convert_patch.dart:1376)
#1 _ChunkedJsonParser.parseNumber (dart:convert-patch/convert_patch.dart:1243)
#2 _ChunkedJsonParser.parse (dart:convert-patch/convert_patch.dart:908)
#3 _parseJson (dart:convert-patch/convert_patch.dart:35)
#4 JsonDecoder.convert (dart:convert/json.dart:610)
#5 JsonCodec.decode (dart:convert/json.dart:216)
#6 ApiClient.deserialize.<anonymous closure> (package:openapi/api_client.dart:158)
#7 compute.<anonymous closure> (package:flutter/src/foundation/_isolates_io.dart:19)
#8 _RemoteRunner._run (dart:isolate:1090)
#9 _RemoteRunner._remoteExecute (dart:isolate:1084)
#10 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:300)
#11 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184)
You know what, I kinda forgot about this because it hasn’t happened in a while.
actually I moved to a new server, same setup on Unraid and running behind CF Tunnel still but I guess I am not overloading the server so it’s fine?
Glad to hear it hasn't been happening! I don't suspect an overload being the issue here, I don't have any big imports or anything going on and the server is pretty beefy.
I think the issue is somewhere in mobile/lib/shared/views/splash_screen.dart:44-62. I'm not sure why the catch is being triggered to begin with, but once it is, it seems to call the .logout() method which explains the second logout failed error and why the app logs itself out.
I don't see anything in the nginx logs indicating any failed backend requests around this time, so I'm pretty stumped. I enabled finest and debug logging, maybe that will help next time. I don't use any Authentik/Authelia/etc, just plain Immich login.
@mmomjian What do you use for your wife to access the instance while not on the local WIFI network?
@alextran1502 sort of a complex deployment, but I run nginx on an Oracle VPS which proxies traffic to my home server over an internal tailscale network. From the perspective of the end user/app, Immich is never "local" - we connect to a public domain name with a real (LetsEncrypt) SSL cert. I run Uptime Kuma to monitor my services, it checks Immich every 10 minutes - I just dropped that to q1min in case there's some kind of weird nginx failure taking place, but all the other services I run have been rock solid.
Thank you for the input, let me try remove that logout condition on the splash_screen to see if it helps
It looks like it is checking at the root instead of at /api. The prior returns html for the website.
@jrasm91 where are you seeing this?
It looks like it is checking at the root instead of at /api. The prior returns html for the website.
That sort of makes sense, because for my login url in the app I use https://subdomain.domain.com, with no /api suffix. However it seems to work fine - except for in this example? I'm not sure how the app checks for the root vs the /api subdomain and if maybe that check is not being done in this case?
It looks like it is checking at the root instead of at /api. The prior returns html for the website.
That sort of makes sense, because for my
login urlin the app I usehttps://subdomain.domain.com, with no/apisuffix. However it seems to work fine - except for in this example? I'm not sure how the app checks for the root vs the/apisubdomain and if maybe that check is not being done in this case?
I have the same issue, for me it logs out about every day or so. i am hosting it behind an proxy but randomly it logs out.
If you woud want logs, i can check for those :)
+1
For me, it happens too. And it’s really annoying. Even my grandma complains that she can’t open photos without entering credentials. 😅
Just had it happen again today. Here's a summary of the logs.
The time of 09:41 is the time at which I opened the app and it was logged out.
09:41: Unable to get user information from the server. From: AuthenticatioNotifier
09:41: Unable to get user information from the server. From: AuthenticatioNotifier
09:42: Ignoring socket cache for http://immichurl
09:42: readyState closed
I switched my login URL to add the /api suffix and will see if that helps.
Not intending to reopen this, but it happened to me today again while using the /api endpoint. Strangely, no logs at all were generated - I had to force close the app and when I reopened, the logs had a 12-ish hour empty spot from yesterday evening to the time I opened it. I know there was another PR merged recently that was related to failing logging so that might fix that as well. I saw a PR was merged to hopefully fix this logout as well.
@alextran1502 unfortunately the same thing happened again this morning.
If you prefer this as a new issue let me know.
Access: public-facing domain name
Server version: 1.102.3 App version: 1.102.0
afaict the fix for this got reverted in #8954 while chasing another logout issue (#8974)
@mmomjian Do you still have the log above that you can share? I would like to see the stack trace of "Unable to get user information from the server"
@alextran1502 cant post a screenshot RN but no stack. Just that message and “from: AuthenticationNotifier”
The only one of those 3 red messages that had a stack is the one I posted.
Screenshots from crash + logout.