Hello. Is it possible to use the realtime subscriptions, when the self-hosted instance is exposed via cloudflare tunnels? There is no additional proxy. I am using latest SDK for next.js and when i try to subscribe to a particular table:
const subString = Channel.tablesdb("<db_id>").table("<table_id>");
const sub = realtime.subscribe(subString, response => {
console.log(response.payload);
});
seems like it does not receive any updates. The state, when logged to console, is 'pending', and no operations in that table can trigger the sub. I tried setting the
.setEndpointRealtime("wss://myappwriteinstance.com/v1/realtime")
but this did not work either.
actually i spotted that I did not await the subscribe() but even with that done - still no results
Same issue here.
Below a react component I created to test the realtime connection. What I found is that only the old way of writing subscriptions works (see attached image which show the logs i receive). The legacy subscription does come through. When i test this same setup, but then with an Appwrite cloud client, it does work. So I assume it has something to do with the self-hosting or setup of it. The current way I host Appwrite is though Coolify, in which I started with the default template, and upgraded from 1.7.4. > 1.7.5 > 1.8.0 > 1.8.1. On each updagrade did a migration if necessary, but still no luck.
Would be great if someone could help!
"use client";
import { useEffect } from "react";
import { Channel } from "appwrite";
import { Client, Realtime } from "appwrite";
export function RealtimeTest() {
useEffect(() => {
const client = new Client()
.setEndpoint(process.env.NEXT_PUBLIC_APPWRITE_ENDPOINT!)
.setProject(process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID!);
const realtime = new Realtime(client);
client.subscribe("rows", (response) => {
console.log("Legacy row event:", response);
});
const startSubscription = async () => {
try {
console.log("Subscribing to realtime events...");
const subscription = await realtime.subscribe(
Channel.rows(),
(response) => {
console.log("New async Realtime event:", response);
},
);
console.log("Subscription created: ", subscription);
} catch (err) {
console.error("Realtime subscribe failed:", err);
}
};
startSubscription();
}, []);
return <></>;
}
Could you please provide logs from the realtime container? I would want to compare it with mine.
I am writing it from the top of my head now, but I believe it was something like docker logs appwrite-realtime
Sure, I don't know if this is what you want, please let me know.
On the right you can see that i created a row, and the event does come in just via the legacy code. But i'm not seeing the event in the left console, so maybe I'm not understanding exactly what you mean.
It is the Coolify dashboard btw.
Can you check whether the heartbeats (ping/pong) working or not on the console? Cause console also uses realtime
Sure, but how exactly do I do that?
Nvm - I got that. Yes, there is working ping/pong
actually there is a bug regarding the tablesdb prefix
in the realtime
also you have to listen to rows and not tables here you should add .rows() or .row(rowId) here
Right - thanks. Also is this a required part of the setup .setEndpointRealtime("wss://myappwriteinstance.com/v1/realtime")? Or can I skip that in case my configuration isn't different than default one?
better to add it, since you are using your self hosted instance
I see. So the tablesdb fix we can expect to be published no sooner than in 1.8.2 release? Or is there maybe a way to track its status?
its merged, will be released in sometime(today most prolly) -> will ping
Recommended threads
- sh: vite: Permission denied
When installing the vue starter template as site and then adding DaisyUI, i get the error `sh: vite: Permission denied`. I also got this issue (with a fresh tem...
- Clean install of 1.9.0 shows errors in a...
I just run a full clean install of Appwrite on my server following the Manual installation guide in the docs page. The console seems to work, visually there d...
- Setup custom domain on selfhosted behind...
Hello everyone, can anyone help me to setup a custom domain on a selfhosted appwrite instance thats running behind cloudflare tunnels? Current setup: Appwrite r...