Hi Guys! 👋 I need your help with the real-time d...
# help
s
Hi Guys! 👋 I need your help with the real-time database feature. I'm trying to make it work and I did every step suggested by the documentation and it is not working as intended. According to the supabase dashboard, it seems like it works because I've got some Realtime Connection Requests, but I'm not getting any events from DB in the app. Steps that I took so far: 1. I enabled replications for the tables I want to subscribe. 2. Wrote logic for getting changes from the todos table:
Copy code
useEffect(() => {
    const todosSubscription = supabase
      .from('todos')
      .on('*', payload => console.log(payload))
      .subscribe()

    return () => {
      supabase.removeSubscription(todosSubscription)
    }
  }, [])
n
Hello @sambor! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
s
Here are some pictures that could be helpful with debugging
BTW. API logs table glitches a bit
g
Do you have RLS on for todos?
n
sambor (2022-04-12)
s
Yes, I've got some rules
Shall I disable them?
g
Your user must meat the select rules
You could do that as a test
s
Nope, unfortunately, it didn't help
g
Did you set up the tables with the UI or use Prisma?
s
With the UI and then I tried SQL apporach with
Copy code
/**
 * REALTIME SUBSCRIPTIONS
 * Only allow realtime listening on public tables.
 */

begin;
  -- remove the realtime publication
  drop publication if exists supabase_realtime;

  -- re-create the publication but don't enable it for any tables
  create publication supabase_realtime;
commit;

-- add tables to the publication
alter publication supabase_realtime add table public.profiles;
alter publication supabase_realtime add table public.todos;
g
Is this hosted or your own server?
s
The application is in the development phase so it is currently served only via localhost
and supabase is on yours servers
g
OK the realtime server is Supabase's hosted service (I'm just a user so yours does not apply)
I'm nervous that you messed with the server publication settings directly, but don't see anything obviously wrong with that. Can you put
Copy code
.subscribe((status) => {console.log('status', status)})
in and see if the connection stays connected? I've sort of run the the usual issues, you might start a support request in case something got messed up on the server side.
s
It returns
status SUBSCRIBED
g
Acting like issue on the server with replication/publication not working.
Another sanity check on RLS is to do a delete as RLS does not apply to it.
s
so what should I do?
g
contact support with the help tab at top right of your instance. Another thought, if you ran your sql code after you set up replication in the UI is to toggle everything off and on and also restart the server under settings.
s
Ok, I will try it 🙂 I want to thank you very much for your help! 🙂
Unfortunately, toggles and restart didn't help as well.
I guess that there is no other way from there than writing to support.
g
I'm out of ideas and hate to keep wasting both our time if something is messed up on the server. I've seen a few of these only resolved by contacting them.
r
@User Were you ever able to fix the issue? Having same/similar issue with getting realtime working
Got it working by updating to latest
supabase-js
👍