Rank 4: Virtual Machine
I think the realtime API for appwrite might be standard enough that using that websocket package might be easier than forking the appwrite sdk.
Votes
0
Replies
24
Participants
Unknown
Messages
25
Rank 4: Virtual Machine
I think the realtime API for appwrite might be standard enough that using that websocket package might be easier than forking the appwrite sdk.
Rank 4: Virtual Machine
From looking at the realtime network requests
If you try it report back how it goes
Rank 4: Virtual Machine
Got it working:
Rank 4: Virtual Machine
Used a more popular web socket package than the one you linked so I don't have to worry about it being supported long term.
Rank 4: Virtual Machine
Rank 4: Virtual Machine
It'll log the heartbeats:
Good to know that it works. web socket channel is somewhat the official version for using websockets, the library I suggested is just a package using it below with their own retry logic and all that jazz on top. the maintainer ain't a noname tho. He is responsible for bloc, mason and other top packages and a well known figure. Nonetheless a good approach you did there
Does is counter the cloudflare 100s disconnect?
Rank 4: Virtual Machine
Yes. The logs you see above are to a hosted thru cloudflare appwrite cluster.
Rank 4: Virtual Machine
Didn't see that, I might pop that package in right now because the retry logic is kinda nice.
It's really needed. I have worked with on a different project where they used websockets and the official package is literally unusable without retry logic.
Because disconnects can happen and especially when the app gets put into the background the realtime connection just gets dropped
or when put into doze which can happen after a few seconds if the app is in the background
Rank 4: Virtual Machine
Here's the updated one using the other package. Stays connected and has a bit better error handling too 🎉
Rank 4: Virtual Machine
@Joshi
That's great 
Have you tried to put the app into doze?
From my experience it takes around 90-120 seconds but would be nice to see if it reconnects afterwards
Rank 4: Virtual Machine
Haven't tried doze. But with the combination of the subscription onDone trigger and AppLifeCycle it should be achievable.
It should reconnect even withput AppLifeCycle no?
Rank 4: Virtual Machine
The fancy package is having issues with the timeout not working for Cloudflare and just reconnects the websocket when it fails every 100 secs. I already had retry logic built into the more popular package, so I'm using that one. Not as fancy retry logic, but it's not hard to implement what is needed.
Can you go a bit more into detail what you mean
Rank 4: Virtual Machine
I couldn't get the timeout to work with the web_socket_client package. So I'm using other package because I can control what is sent as the heartbeat package and when it is sent too (doesn't need to be sent until 100 sec after the last sent package).
Rank 4: Virtual Machine
It's working well. The only downside is I have to manage the reconnect logic myself which isn't hard.