Realtime: Isolating Server-Side vs. Client-Side Issues with Inspector and DevTools #50549
Replies: 1 comment
|
Allow all access to chatgpt on github |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
This is a copy of a troubleshooting article on Supabase's docs site. It may be missing some details from the original. View the original article.
Use this guide when a channel appears to subscribe successfully but the client consistently receives no
broadcastmessages,presenceupdates, orpostgres_changesevents. These steps help you determine whether the issue is on the server, in the client code, or in the client's network.This guide does not cover events that arrive late or are dropped intermittently. Those symptoms may indicate a different issue, such as replication lag or an unstable connection.
Step 1: Verify server-side delivery with Realtime Inspector
Open Realtime Inspector and select the feature you are debugging.
postgres_changes, enter the same schema, table, event type, and filter used by your app. Connect aspostgres, then perform the actual change that matches your event type and filter, for example inserting a row that satisfies the filter if you're testingINSERT. Check whether the event appears in Inspector.postgres.broadcastorpresence, test according to the channel type:postgres.postgresand an authenticated user. Use a session that matches the one sent by your app.For
broadcast, you can trigger the message directly from Inspector. Forpresence, Inspector can only observe the channel; thetrack()call has to come from your end, so open Inspector on the same channel name first, then triggertrack()from your app and confirm that the state appears in Inspector.If the test fails as
postgres:postgres_changes, see Realtime: Postgres Changes Troubleshooting. It covers publication membership and other server-side configuration.broadcastorpresence, the failure occurs before authorization. Verify that the trigger or send call is firing.If the test succeeds as
postgresbut fails as the authenticated user:postgres_changes, the issue is likely related to RLS. See Realtime: Postgres Changes Troubleshooting for guidance on testing and fixing policies.broadcastorpresence, the issue is likely related to channel authorization onrealtime.messagesfor that role. Review the policy examples in the Realtime Authorization docs. Also check whether a complex policy is causing authorization checks to run slowly or time out.If both tests succeed: The Realtime server and Postgres are working as expected. The issue is likely in the client or network path. Continue to Step 2.
Step 2: Check the client configuration
Check for these common configuration issues:
postgres_changes: Confirm that the filter, schema, table, and event type match. See the "Check the subscription code itself" section of Realtime: Postgres Changes Troubleshooting for common mismatches.broadcast: Confirm that the sender and receiver use the same topic and event name.presence: Confirm thattrack()is called after the channel reachesSUBSCRIBEDand that all clients use the same channel name.Also make sure you are using a recent version of
@supabase/supabase-jsand, if pinned separately,@supabase/realtime-js. Older versions may contain bugs that cause events to be dropped.If the configuration and package versions are correct but events still do not arrive, continue to Step 3.
Step 3: Inspect connection traffic in browser developer tools
wss://<project-ref>.supabase.co/realtime/v1/websocket.(Note: If your app connects on page load, refresh the page while DevTools is open).phx_joinmessage and its correspondingphx_reply.Use the captured messages to determine what happened, then act accordingly:
Step 4: Check the network path
Confirm that the WebSocket request to
wss://.../realtime/v1/websocketreceives a101 Switching Protocolsresponse.If it does not, or if the console reports a TLS or certificate error, a firewall, proxy, or SSL-inspecting network appliance may be blocking the connection before it reaches Realtime.
Try testing the same app on a completely different network to confirm if the issue is network-specific.
If you still need help, contact Support and include a description of the issue, relevant results of these tests, and the troubleshooting steps you've already tried. This information will help narrow down the cause.
All reactions