we are building a chat functionality in our app bu...
# help
s
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
Did you enable realtime on that table? by default realtime is turned off If I remember correctly
s
Yes. It was enabled when we wrote the subscription code. The code is still not working.
g
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
ok. I will try that and let you know. I did not check the network websocket request. I will check that too.
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
HMMM . You might try 'asterisk' see if you get anything.
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?