realtime-py icon indicating copy to clipboard operation
realtime-py copied to clipboard

Unable to get realtime connection to Supabase locally

Open JamesLloydPartington opened this issue 3 years ago • 2 comments

I am currently trying to use realtime.connection.Socket() with Supabase locally. I am following this guild (https://supabase.com/docs/guides/local-development). I am using a MacBook Pro with an M1 chip, realtime==0.0.4.

From the Supabase guide, I have run "supabase start" and "docker ps" in the terminal: Terminal screenshot

Sample code to run:

from realtime.connection import Socket
# local service key
SUPA_SERVICE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSJ9.vI9obAHOGyVVKa3pD--kJlyxp-Z2zV9UUMAhKpNLAcU"

HOST_PORT = 54321

SUPA_REALTIME_URL = f"wss://localhost:{HOST_PORT}/realtime/v1/websocket?apikey={SUPA_SERVICE_KEY}&vsn=1.0.0"

s = Socket(SUPA_REALTIME_URL)
s.connect()

After running this code I get: Screenshot 2022-06-28 at 13 24 58

Could this be because of the SUPA_REALTIME_URL being incorrect? I have tried several different HOST_PORT shown in "docker ps" with no success.

JamesLloydPartington avatar Jun 28 '22 12:06 JamesLloydPartington

Have you tried with the official supabase JS realtime library? I've never used Supabase locally to be honest

odiseo0 avatar Jun 29 '22 17:06 odiseo0

I have and it worked fine. My backend is mainly in python, so it would be convenient for it to work with python too.

JamesLloydPartington avatar Jun 30 '22 13:06 JamesLloydPartington

@JamesLloydPartington did you ever figure this out?

chitalian avatar Nov 18 '22 22:11 chitalian

@chitalian Unfortunately I have not.

JamesLloydPartington avatar Nov 18 '22 22:11 JamesLloydPartington

oh my gosh @JamesLloydPartington you might facepalm at this one... wss -> ws

chitalian avatar Nov 18 '22 22:11 chitalian

however. I am running into another issue now lol https://github.com/supabase/realtime/issues/347

But I think you can probably close this issue :)

chitalian avatar Nov 18 '22 23:11 chitalian

I do remember trying both wws and ws a while back. But neither of those worked. Since you have a new issue open, I'll close this one.

JamesLloydPartington avatar Nov 19 '22 09:11 JamesLloydPartington

@JamesLloydPartington

I do remember trying both wws and ws a while back. But neither of those worked. Since you have a new issue open, I'll close this one.

Yeah they are actually going to get it to work here https://github.com/supabase/cli/pull/594

this should work, I got it to connect successfully. Let me know if you need any help running it locally :) for me it was just doing ws

chitalian avatar Nov 19 '22 09:11 chitalian