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
- login With OAuth Failed
login With OAuth Failed: when i cliick to login with any of the following (facebook, gmail or apple) am being redirected out of the app to enter my detail, afte...
- Flutter OAuth2 webAuth Bug?
I created with flutter an app where I can login in with my Microsoft Account. When I compile it to Web (WASM) or Android (aab) then there is no problem what so ...
- Synchronous Function Execution Timed Out...
Hi Appwrite team 👋 I’m facing a synchronous function execution timeout issue on Appwrite Cloud and would appreciate some guidance. I executed this function u...