-
-
Notifications
You must be signed in to change notification settings - Fork 395
Closed
Labels
Description
Bug report
Describe the bug
I'm trying to establish a realtime subscription with a self-hosted Supabase instance through Caddy as a reverse proxy but I'm getting the following error:
WebSocket connection to 'wss://db.mydomain.com/realtime/v1/websocket?apikey=my.jwt.key&vsn=1.0.0' failed
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create a self-hosted setup as described in the Supabase docs.
- Setup Caddy as a reverse proxy
https://db.mydomain.com {
reverse_proxy /rest/v1/* localhost:8000
reverse_proxy /auth/v1/* localhost:8000
reverse_proxy /realtime/v1/* localhost:8000
reverse_proxy /storage/v1/* localhost:8000
reverse_proxy * localhost:3000
}
- Create a test table and setup a subscription to it.
const supabase = createClient(
"https://db.mydomain.com",
"my.jwt.key"
);
supabase
.channel("*")
.on(
"postgres_changes",
{
event: "*",
schema: "public",
table: "test_table",
},
(payload) => {
console.log(payload)
}
)
.subscribe();
Expected behavior
I should be able to establish a websocket connection and listen to changes in the table, just like the SaaS version of Supabase.
System information
- OS: Linux
- Browser (if applies) Firefox
- Version of supabase-js: 2.7.0
- Version of Node.js: 18
Additional context
- I can insert records with
supabase-js
with no issues using this setup. - Kong container logs:
supabase-kong | 172.18.0.1 - - [03/Feb/2023:17:04:51 +0000] "GET /realtime/v1/websocket?apikey=my.jwt.key&vsn=1.0.0 HTTP/1.1" 500 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
- Realtime container logs:
realtime-dev.supabase-realtime | Request: GET /socket/websocket?apikey=my.jwt.key&vsn=1.0.0
realtime-dev.supabase-realtime | ** (exit) an exception was raised:
realtime-dev.supabase-realtime | ** (MatchError) no match of right hand side value: {:error, :tenant_not_found_in_host}
realtime-dev.supabase-realtime | (realtime 2.0.0) lib/realtime_web/channels/user_socket.ex:22: RealtimeWeb.UserSocket.connect/3
realtime-dev.supabase-realtime | (phoenix 1.6.13) lib/phoenix/socket.ex:550: Phoenix.Socket.user_connect/6
realtime-dev.supabase-realtime | (phoenix 1.6.13) lib/phoenix/socket.ex:438: Phoenix.Socket.__connect__/3
realtime-dev.supabase-realtime | (phoenix 1.6.13) lib/phoenix/transports/websocket.ex:33: Phoenix.Transports.WebSocket.connect/4
realtime-dev.supabase-realtime | (phoenix 1.6.13) lib/phoenix/endpoint/cowboy2_handler.ex:22: Phoenix.Endpoint.Cowboy2Handler.init/4
realtime-dev.supabase-realtime | (cowboy 2.9.0) /app/deps/cowboy/src/cowboy_handler.erl:37: :cowboy_handler.execute/2
realtime-dev.supabase-realtime | (cowboy 2.9.0) /app/deps/cowboy/src/cowboy_stream_h.erl:306: :cowboy_stream_h.execute/3
realtime-dev.supabase-realtime | (cowboy 2.9.0) /app/deps/cowboy/src/cowboy_stream_h.erl:295: :cowboy_stream_h.request_process/3