we are building a chat functionality in our app but our realtime subscription is not working. We store our chats in a table called "messages". Here is the code that we are using.
let chatSubscription = supabase
.from('messages')
.on('INSERT', payload => {
console.log('Change received!', payload)
})
.subscribe()
The above code is never called when we insert new messages. We do have the realtime replication enabled for the table.
Any help will be appreciated. Thanks.
s
silentworks
10/27/2021, 5:31 PM
Did you enable realtime on that table? by default realtime is turned off If I remember correctly
s
spiderz
10/27/2021, 5:36 PM
Yes. It was enabled when we wrote the subscription code. The code is still not working.
g
garyaustin
10/27/2021, 8:50 PM
Does the network websocket request go out for the subscribe? In other words is that code actually running? You can also put a console.log in your subscribe function (status)=>console.log(status) to see if there was an error.
s
spiderz
10/28/2021, 12:49 AM
ok. I will try that and let you know.
I did not check the network websocket request. I will check that too.
spiderz
10/31/2021, 1:39 AM
I did the (status)=>console.log(status) and it logs "SUBSCRIBED" so I guess it does subscribed. I also checked the Websockets and I see the log there.
However, when I INSERT a new record, I still don't get any payload back.
g
garyaustin
10/31/2021, 2:34 AM
HMMM . You might try 'asterisk' see if you get anything.
garyaustin
10/31/2021, 2:55 AM
Also do you have insert turned on in the first part of the UI replication section before you go to the section where you select which tables?