Skip to content
Back

Realtime fails to connect/reconnect

  • 0
  • Web
  • Cloud
Trevor Arapu
31 Mar, 2026, 10:39

I have been having trouble with my appwrite realtime connection for a few days now. Before the code that was working fine now is giving failed to connect errors

TL;DR
Developers are facing issues with their Realtime connection in their appwrite application. Despite trying different browsers, private mode, and changing databases, the issue persists. They have provided code snippets for the Realtime setup and network tab information. The problem seems to be with the immediate connection and disconnection.
Trevor Arapu
31 Mar, 2026, 10:41

this is the network tab

Trevor Arapu
31 Mar, 2026, 10:43

each socket name/header

Trevor Arapu
31 Mar, 2026, 10:44

messages

Trevor Arapu
31 Mar, 2026, 10:45

After the initial data has been fetched, This is the setup 'import { defineStore } from 'pinia'

export const useRealtime = defineStore('realtime', { state: () => ({ subscription: null, started: false }),

TypeScript
actions: {
    async startWatch() {
        if (this.started) return

        const { realTime, Query } = useAppwrite()
        const forNotifications = useNotifications()
        // more stores here...

        const forUserCreds = useUserCreds()
        const forUserCredsId = computed(() => forUserCreds.mdV4UserId)
        const config = useRuntimeConfig().public

        const channels = [
            `databases.${config.APPWRITE_DB_ID}.tables.${config.APPWRITE_USERNOTIFICATIONS_COLL}.rows`,
            // more channels here...
        ]

        this.subscription = await realTime.subscribe(channels, (res) => {
            const row = res.payload
            if (!row) return

            const id = row.$id
            const eventsVals = Object.values(res.events)

            // NOTIFICATIONS
            if (forNotifications.handles(row)) {
                forNotifications.applyRealtime(id, row, eventsVals)
            }

            // more handlers here...

        }, [
            Query.or([
                Query.equal('userId', forUserCredsId.value),
                Query.equal('$id', forUserCredsId.value)
            ])
        ])

        this.started = true
    },

    endWatch() {
        if (this.subscription) this.subscription.close()
        this.subscription = null
        this.started = false
    }
}

})'

Trevor Arapu
31 Mar, 2026, 10:46

I have tried different browsers, private mode, and changing databases to tablesdb in for each channel, but still get the same error

Trevor Arapu
31 Mar, 2026, 10:47

Could this be a skill issue on my end 🤣

Trevor Arapu
31 Mar, 2026, 10:49

In this it shows that it connects and disconnects immediently

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