Back

Realtime only emits events with guest / any read permissions

  • 0
  • Self Hosted
  • Flutter
  • Realtime
V
19 Aug, 2024, 16:45

Im currently trying to get this example to work

TypeScript
late final Session session;
  try {
    session = await account.getSession(sessionId: "current");
  } on AppwriteException catch (e) {
    print(e.message);
    session = await account.createEmailPasswordSession(
        email: "t@t.t", password: "testtest");
  }
  print("Session: $session");

  final realtime = Realtime(client);
  final realtimeSub = realtime.subscribe(
    ["documents"],
  );
  realtimeSub.stream.listen((event) {
    print("Realtime event");
  });

  await Future.delayed(const Duration(seconds: 3));

  final customer = {
    "id": 123456,
    "name": "John Doe",
  };

  final response = await database.createDocument(
    databaseId: "default",
    collectionId: "customers",
    documentId: ID.unique(),
    data: customer,
  );

  print("Document: $response");

  final customers = await database.listDocuments(
    databaseId: "default",
    collectionId: "customers",
  );

  print("Customers: ${customers.documents}");

If the collections has create permission for the user and document security enabled then i dont receive a realtime event If the collection has the same permissions + read permissions for guests then im able to receive the realtime event

So im not sure what exactly im doing wrong. Am i creating the subscription wrong or am i missing something with the permissions?

TL;DR
Developers are experiencing issues when trying to use Realtime feature in their code. Realtime events are only emitted when the collection has read permissions for guests. Realtime events are not received if the create permission is only set for the user, even with document security enabled. Check subscription creation and permissions settings.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more