Back

Realtime - Struggling to get anything working

  • 0
  • Realtime
Pingu
23 Jan, 2025, 01:44

Hey, so I'm not particularly js-native so its likely I've done something obviously wrong...

I am looking at using realtime but in .net - but in order to do so I need to understand how things work.

I've build myself a very small project to test it out in javascript, but I don't seem to be able to get it working fully.

I've npm installed appwrite and vite, and am running a simple thing with vite.

my index.html:

TypeScript
<!DOCTYPE html>
<html>
  <head>
    <title>JavaScript Sandbox</title>
    <meta charset="UTF-8" />
  </head>

  <body>
    <div id="app"></div>

    <script src="./index.mjs" type="module"></script>
  </body>
</html>

and my index.mjs:

TypeScript
import { Client } from "appwrite";

const client = new Client()
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject("675ef042003413f106ba");

// Subscribe to files channel
client.subscribe(["databases.676a27c20025b8a2689b6.collections.6786ac01000d0404b9f7.documents", "documents"], (response) => {
  console.log(response.payload);
});

I load the page vite spins up for my on localhost, and inspect the network in chrome dev tools.

I can see the websocket is connected to, and it sends my subscriptions. When I update a document within the database, within the specified collection, however, I see no updates.

The collection does not have any permissions or document security setup.

I've also attempted to see the login flow, and have run the same js but using setSession as well, and I never see it respond to the connected message like I would expect it to.

I do see regular ping/pong messages being sent and receieved, however.

I also see 0 realtime connections and no data to show on the overview for the project. (I have triple checked that its the correct project)

Have added screenshot of ws conenction, and 0 realtime connection in dashboard.

TL;DR
Developers are struggling to get Realtime working with Appwrite in a JavaScript project using Vite. They are unable to see updates when a document in a specified collection is updated. They have checked permissions and document security but still no luck. In addition, the login flow does not respond as expected. Realtime connections and data overview in the dashboard are not showing any information. Potential solution: - Double-check all settings and permissions for the specified collection. - Ensure proper setup of the login flow with `setSession`. - Verify the connection details and project ID. - Investigate further if the websocket is properly receiving and handling updates.
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