© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•8mo ago•
65 replies
volfpe

Realtime Broadcast events are not received when sent from database trigger

Hello. This is my database trigger that broadcasts the message:
CREATE OR REPLACE FUNCTION public.messages_broadcast_changes()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
  if coalesce(NEW.job_id, OLD.job_id) is not null then
    perform realtime.broadcast_changes(
      'test',
      TG_OP,                                                -- event: INSERT/UPDATE/DELETE
      TG_OP,                                                -- operation: same as event
      TG_TABLE_NAME,                                        -- table
      TG_TABLE_SCHEMA,                                      -- schema: public
      NEW,                                                  -- new record
      OLD                                                   -- old record
    );
  end if;
  
  return null;
end;
$function$
;
CREATE OR REPLACE FUNCTION public.messages_broadcast_changes()
 RETURNS trigger
 LANGUAGE plpgsql
 SECURITY DEFINER
AS $function$
begin
  if coalesce(NEW.job_id, OLD.job_id) is not null then
    perform realtime.broadcast_changes(
      'test',
      TG_OP,                                                -- event: INSERT/UPDATE/DELETE
      TG_OP,                                                -- operation: same as event
      TG_TABLE_NAME,                                        -- table
      TG_TABLE_SCHEMA,                                      -- schema: public
      NEW,                                                  -- new record
      OLD                                                   -- old record
    );
  end if;
  
  return null;
end;
$function$
;


The trigger gets called and it successfully creates a new row in
realtime.messages
realtime.messages
table with the
test
test
topic and correct data. However, I'm not able to receive the event in my client application. Even when using the realtime inspector with the service role, the event won't show up in the UI.

When sending the event from the realtime inspector (using the "Broadcast a message" button), the client receives the event.

I'm using the private channel and I simplified the Policy to allow everything.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements
Next page

Similar Threads

Broadcast to realtime from server
SupabaseSSupabase / help-and-questions
4mo ago
Supabase Realtime Broadcast Not Working from C# Backend
SupabaseSSupabase / help-and-questions
4mo ago
Realtime event callback does not fire, but events are received in websocket messages
SupabaseSSupabase / help-and-questions
4y ago
Realtime not receiving events
SupabaseSSupabase / help-and-questions
4y ago