#Is realtime API down?

36 messages · Page 1 of 1 (latest)

gentle lantern
#

Been playing around with the realtime API but all of a sudden it stopped working. 🤔

#

I get Realtime got disconnected. Reconnect will be attempted in 1 seconds.

Not sure it's because I switch tabs tho' or not.

prisma pivot
gentle lantern
#

does it have some limitations?

#

it worked for one second, now it stopped again

prisma pivot
#

What's your code?

#

Could be a network issue too

gentle lantern
#
const unsubscribe = client.subscribe(
    `databases.${DB_ID}.collections.${COLLECTION_ID}.documents`,
    (res) => {
        console.log({ res });

        if (
            res.events.includes(
                "databases.*.collections.*.documents.*.update"
            )
        ) {
            setQuestions((prevQuestions) => {
                return prevQuestions.map((question) => {
                    if (question.$id !== res.payload.$id) {
                        return question;
                    }

                    return res.payload;
                });
            });
        }
        console.log("UPDATED QUESTIONS");
    }
);```
#

and I have a button that updates this collection

#

and I'm waiting to see the update (and the console log)

prisma pivot
gentle lantern
#

well, that's just me storing the unsubscribe method

#

so that I can call it at the end of the useEffect

#
useEffect(() => {
    getQuestionsFromDB();

    const unsubscribe = client.subscribe(
        `databases.${DB_ID}.collections.${COLLECTION_ID}.documents`,
        (res) => {
            console.log({ res });

            if (
                res.events.includes(
                    "databases.*.collections.*.documents.*.update"
                )
            ) {
                setQuestions((prevQuestions) => {
                    return prevQuestions.map((question) => {
                        if (question.$id !== res.payload.$id) {
                            return question;
                        }

                        return res.payload;
                    });
                });
            }
            console.log("UPDATED QUESTIONS");
        }
    );

    return () => {
        unsubscribe();
    };
}, []);
#

this is the entire useEffect inside of my App.jsx

#

this code worked, I haven't changed anything but then the event stopped firing

#

are there any limitations? 🤔

#

btw, the update method works too, I just don't get the realtime event and I have to manually refresh the page

prisma pivot
#

But I think it's not the case

#

Thai is Appwrite cloud, right?

gentle lantern
#

no, I'm just testing this on localhost

#

yes

prisma pivot
#

Ok. Do you can send me your project ID?

gentle lantern
#

sure: 6694b8f8000ff3696830

prisma pivot
#

cc @last rune

gentle lantern
#

ok, now it seems to be back

#

🤷‍♂️

#

no changes in my code

prisma pivot
#

Steven will take a look soon into it to check logs and see if there's an issue from Appwrite's side and your specific project

gentle lantern
#

thank you

prisma pivot
#

Maybe it's an issue with your network 🤔🤷‍♂️

#

No idea, sincerely 😅

gentle lantern
#

well, I can chat with you here and all the other apps that are connected to the internet are working fine 😅

last rune