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
- Compatibility issue with Kakao OpenID Co...
**Context:** I am attempting to integrate **Kakao Login** (one of the largest social login providers in South Korea) into my Flutter application using Appwrite'...
- [SOLVED] Appwrite 25.1.0 returns Invalid...
I've already opened an issue on GitHub, but somewhat it doesn't seem like GitHub is monitored very closely, so I'm leaving a bug report here on Discord as well....
- listRows result parsing issue
I'm using Appwrite Dart SDK "24.2.0". When I perform a listRows call in dart, I have this reponse in JSON: in " Future<models.RowList> listRows()" { "total" :...