Rank 3: Container
Hi, I am trying to connect my tables rows with realtime on my react website, it connects, but I dont get the rows when a row is being created. I tried with Channels etc, but nothing seems to work.
Votes
0
Replies
24
Participants
5
Messages
25
Rank 3: Container
Hi, I am trying to connect my tables rows with realtime on my react website, it connects, but I dont get the rows when a row is being created. I tried with Channels etc, but nothing seems to work.
2 common issues:
make sure you're using matching terminology to the one you use in your API (documents vs rows)
make sure your listening user have permissions to see the rows/documents that fire the events
Rank 3: Container
I also have a android app in production with realtime active and it was working before but now it doesnt for the past 2 days when checked it out.
Rank 3: Container
Even my webapp in production is failing as well
Can you share any error messages if coming?
I tested with my projects, I am able to connect and receive messages as well
I guess you are getting some error messages as well can you share them along with your projectid
Rank 3: Container
okay cool
Rank 3: Container
It shows the error and just loops contantly,
Rank 3: Container
It keeps reconnecting constantly, but I never recieve anything when a database change is made
Rank 3: Container
headers
check here whats in the messages tab
Rank 3: Container
it seems to be empty
Feeling like it's not even hitting the realtime service 🤔
Can you check whether locally things working or not ?
Whether you are able to hit the realtime service or not
Rank 3: Container
I was before and everything was working fine
Rank 3: Container
with realtime perfect
Rank 3: Container
can I share a code sample
Rank 3: Container
But Calling the Api and getting initial data before firing up the realtime everything is working but the only issue comes from the realtime.
Rank 3: Container
This is the setup 'import { defineStore } from 'pinia'
export const useRealtime = defineStore('realtime', {
state: () => ({
subscription: null,
started: false
}),
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
}
}
})'
i think your using wrong channels : https://appwrite.io/docs/apis/realtime/channels
your showing databases but it's tablesdb
it's possible that appwrite realtime force disconnect you if no channels match or if your using non-existing ones
Rank 3: Container
Could be but the thing is, all this was working perfectly until a few days ago but let me check the docs. Thank you
Rank 3: Container
i switched from databases to tablesdb but still
Rank 3: Container
is this what you meant tablesdb.${config.APPWRITE_DB_ID}.tables.${config.APPWRITE_USERNOTIFICATIONS_COLL}.rows