I have a document that is the user profile. I try to subscribe to any changes by doing:
var s = realtime.subscribe(['databases.app.collections.profile.documents.${_social.awAccount!.$id}']);
s.stream.listen((event) {
Log.w(event.toString());
}, onError: (a) {
Log.e(a.toString());
}, onDone: () {
Log.e('profile connection closed');
});
I have another use case: subscribing to a chat collection, where a document is a chat message:
realtime.subscribe(['databases.chat.collections.${widget.group}.documents']);
After cloud upgrade I've been getting the streams to call onDone
and connection is lost. I've just noticed this issue recently, because the users are complaining about chat connection issue.
The users have permission to that document and collection. The users can do database.listDocuments
for chat collection, so they really have permission.
I am using the current flutter sdk 11.0.0 and appwrite cloud. I read the docs again, and I couldn't figure out if anything was changed from previous sdk version. The problem is occurring in both Android and iOS devices, in different networks (wifi, 5g)
The logs for the chat code:
subscription: wss://cloud.appwrite.io/v1/realtime?project=REALPROJECTID&channels%5B%5D=databases.chat.collections.k82rekh0jl9zrep.documents
[chat] Connection closed
Also tried ending with documents.*
but no success.
- is not allowed for realtime channels.
Are you using multiple instances of realtime?
No, same instance. I cut the url to be short, but both subscriptions are shown in that log. I tried subscribing just one example or another, and I have same result.
What do you mean with "is not allowed for realtime channels"? Is it * ?
I mean the list of valid channels are here: https://appwrite.io/docs/apis/realtime#channels and you must use an ID. You can't use wildcards
Try using different realtime instances for each subscription
It was just a try. But the current code doesn't use wild card.
realtime.subscribe(['databases.chat.collections.${widget.group}.documents']);
Result:
databases.chat.collections.k82rekh0jl9zrep.documents
This was working before, users could chat in real time, by receiving the messages in that collection.
I tried, same problem.
When does the disconnect happen?
About 1 second after subscription.
Interesting... What if you only subscribe once?
Do you mean, subscribe only one channel? I'm doing that already. I have removed the profile subscription. Actually I tried to subscribe just profile doc, and just chat collection's docs to test, but I have the same connection issue in both cases.
One subscription
Yes, I meant that. One subscription
One subscription to profile doc only and no other realtime subscriptions, right?
Yes. I removed the other one to test. And the same disconnection happens.
And if I try to get the document (or the list of documents) it works normally.
You mean databases.getDocument()
or databases.listDocuments()
?
@fernandoxlr so there was a problem with realtime but it should be fixed now. Are you still seeing the problem?
Oh, good to know π
Yeah, it seems to be working now π
The chat function in my app is back
[SOLVED] Unable to establish a realtime subscription connection
Recommended threads
- Update User Error
```ts const { users, databases } = await createAdminClient(); const session = await getLoggedInUser(); const user = await users.get(session.$id); if (!use...
- Our Appwrite organization is suspended
Please give support regarding this , no app is working now , please solve my issue and give support , no one is replying in message section or email.
- Project in AppWrite Cloud doesn't allow ...
I have a collection where the data can't be opened. When I check the functions, there are three instances of a function still running that can't be deleted. The...