https://supabase.com/ logo
#help
Title
# help
s

sambor

04/12/2022, 8:56 PM
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

Needle

04/12/2022, 8:56 PM
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

sambor

04/12/2022, 8:58 PM
Here are some pictures that could be helpful with debugging
BTW. API logs table glitches a bit
g

garyaustin

04/12/2022, 9:03 PM
Do you have RLS on for todos?
n

Needle

04/12/2022, 9:03 PM
sambor (2022-04-12)
s

sambor

04/12/2022, 9:05 PM
Yes, I've got some rules
Shall I disable them?
g

garyaustin

04/12/2022, 9:05 PM
Your user must meat the select rules
You could do that as a test
s

sambor

04/12/2022, 9:10 PM
Nope, unfortunately, it didn't help
g

garyaustin

04/12/2022, 9:11 PM
Did you set up the tables with the UI or use Prisma?
s

sambor

04/12/2022, 9:12 PM
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

garyaustin

04/12/2022, 9:16 PM
Is this hosted or your own server?
s

sambor

04/12/2022, 9:17 PM
The application is in the development phase so it is currently served only via localhost
and supabase is on yours servers
g

garyaustin

04/12/2022, 9:19 PM
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

sambor

04/12/2022, 9:27 PM
It returns
status SUBSCRIBED
g

garyaustin

04/12/2022, 9:28 PM
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

sambor

04/12/2022, 9:33 PM
so what should I do?
g

garyaustin

04/12/2022, 9:35 PM
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

sambor

04/12/2022, 9:37 PM
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

garyaustin

04/12/2022, 9:58 PM
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

rustamd

04/21/2022, 3:45 AM
@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
👍