When the subscription auto-closes after 100 second, the key question is: How can we effectively handle scenarios where the user interacts with the app, actively listening, and then leaves the app in the background for an extended period before returning to reuse it? rebuild new subscription every 1 min better or make auto update every 1min for Prevent close the subscription
It shouldn't be auto closing after a minute? Is your server behind Cloudflare?
Yes, it is!
Yeah, IIRC, CF closes idle WebSockets connections after one to two minutes.
I don't think there's any way to disable that
If you want to automatically reopen, you could listen for the socket close event, and create a new connection when that happens?
It's after 100 seconds
i edited the first message for 100 seconds
Well, best would be to have that route bypass CF and not time out (I think that's possible, but not on the free plan. Alternatively, you could have a separate endpoint that doesn't go through CF for the WebSockets)?
Of course, once the user leaves the app in the background, it's likely it'll have all connections closed by battery saving, anyway. You could then recreate the onnection when the user re-enters the app
Should i keep sending a light request to refresh the subscription every 90 seconds or create a new subscription every 90 seconds which is better ?
If you have to choose between opening a new connection every minute and updating a document (to keep the connection alive) every minute, I'd say keep the connection alive
No,Now the question is: Sending a light request to refresh the subscription every 90 seconds or create a new subscription but when user interact with the app after 90 seconds (or more, may be 5 min) which is better ? what is the choosing caused ?
I assume by interact with the app you just mean the app is active?
I mean that the user is clicking on any part of the app screen.
Well, what are you using Realtime for?
I am using this for a chat AI app. There are instances when the user leaves the app without closing it.
But what are you doing with Realtime?
Recommended threads
- Weird permission failure
when creating an account I use following methods: ``` Future<void> register(String email, String password, String username) async { final user = await accoun...
- Flutter Android oAuth is no more working
I currently don't get the oAuth login to work in flutter android. it works on ios and on web. but when try to use it on Android, i get to the point where the ca...
- I'm experiencing a critical bug on Appwr...
Hey <@870607367597850624> team / support 👋 I'm experiencing a critical bug on Appwrite Cloud that's blocking my production Flutter app. I've already filed GitH...