Skip to content
Back

Realtime fails to connect/reconnect

  • 0
  • 4
  • 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
User experienced connection issues with their Realtime feature. After troubleshooting by updating the appwrite SDK and channel structure, adding vercel as a platform identifier fixed the issue in both dev and prod environments. The real-time feature started working properly after applying these changes. However, later on, user encountered errors in production after adding wildcard(*) to platforms. By revisiting the documentation, modifying code to fit SDK updates, and not solely relying on real-time, user resolved the issue. The team confirmed that the WebSocket issue was due to an origin problem. The user thanked everyone for their assistance and emphasized the importance of thorough documentation review and immediate user feedback implementation
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

31 Mar, 2026, 16:11

can you try again? Are you still seeing issues?

31 Mar, 2026, 16:18

have you tried browsing to https://fra.cloud.appwrite.io in your browser?

31 Mar, 2026, 19:52

Yap just checked right now and am getting the issue

31 Mar, 2026, 19:56

Yap, fra.cloud.appwrite.io works perfectly

1 Apr, 2026, 16:55

oh wait this is the websocket issue. Are you still seeing the issue?

1 Apr, 2026, 18:00

Let me check,

1 Apr, 2026, 18:11

Nope still failing

3 Apr, 2026, 00:00

what's your project id?

3 Apr, 2026, 00:00

i still can't reproduce

3 Apr, 2026, 00:03

where is your app running from?

3 Apr, 2026, 09:33

Am testing on localhost(dev) but in prod its vercel

3 Apr, 2026, 09:34

I looked at the docs and found some changes where made to the channel structure

3 Apr, 2026, 09:35

Am this is mine πŸ˜‚

3 Apr, 2026, 09:35

Let me make the modifications and test again

3 Apr, 2026, 11:06

well still getting this

3 Apr, 2026, 11:08
3 Apr, 2026, 11:09
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