Open vegabook opened 2 years ago
What are you trying to achieve? I'm not very knowledgeable with supabase realtime but I thought it only supported sending you realtime updates as they happen to the database, what functionality exists that would need you sending something to the phoenix server?
What are you trying to achieve? I'm not very knowledgeable with supabase realtime but I thought it only supported sending you realtime updates as they happen to the database, what functionality exists that would need you sending something to the phoenix server?
Phoenix has fully bidirectional clients for multiple languages but none for python. This seems the closest but is unidirectional. I wish to communicate from python to phoenix both ways and this library looks like a good starting point. My use case is unrelated to supabase.
Ah got it. This repo has sort of been on the backburner for us while we worked on the other supabase - python features, hence the lack of features. Sadly I don't have the time right now to implement this feature, but I'd be happy to review and merge any PRs.
Unrelated but I am curious -- does your usecase leverage asyncio, or is it all sync code? I ask this because right now this project does some hacky stuff to provide a sync interface to the otherwise async websockets
methods and I was planning on making this repo async only too.
@vegabook
Ah got it. This repo has sort of been on the backburner for us while we worked on the other supabase - python features, hence the lack of features. Sadly I don't have the time right now to implement this feature, but I'd be happy to review and merge any PRs.
Unrelated but I am curious -- does your usecase leverage asyncio, or is it all sync code? I ask this because right now this project does some hacky stuff to provide a sync interface to the otherwise async
websockets
methods and I was planning on making this repo async only too.@vegabook
I'm quite happy to go fully async, so if you wanted to let me know where the hacks are, also happy to take a look at those.
I will take a stab at putting in some basic bidirectionality too.
@vegabook searching for loop.run_until_complete
in realtime/connection.py
should get you most of the places where we wrap async calls
@vegabook Have you found a viable solution for this? I'll be giving https://github.com/wwww-wwww/phxsocket a whirl this weekend, as I also need a bidirectional Phoenix Channel client.
@silentsilas Did you manage to make phxsocket work with supabase?
Ah I just needed to be able to run a Python script, and send/receive messages from it. Elixir's Port ended up doing the job without needing to modify my scripts to use Websockets.
Is it possible to have a channe.send() script? I'm not familiar with the Websocket structures Supabase uses, I tried to run a simple "websocket.send" using websocket-client
library, but couldn't figure out how the channels work.
URL = f"wss://{SUPABASE_ID}.supabase.co/realtime/v1/websocket?apikey={API_KEY}&vsn=1.0.0"
# Create a WebSocket connection to the specified URL
ws = websocket.WebSocket()
ws.connect(URL)
# Send a message over the WebSocket connection
ws.send("Hello, World!")
🔼 this is received by supabase's server (I can see the number of messages being increased) but the other Python client doesn't see these messages
channel_1 = s.set_channel("*")
channel_1.join().on("*", callback1)
We need this. For Python to be on the backburner is not great. I will dedicate work to this but it's difficult to know exactly what supabase is expecting. Websockets are not hard. I wish the site had a raw Websockets version of the docs. Can we at least get that?
edit: just reversing the js client
We need this. For Python to be on the backburner is not great. I will dedicate work to this but it's difficult to know exactly what supabase is expecting. Websockets are not hard. I wish the site had a raw Websockets version of the docs. Can we at least get that?
edit: just reversing the js client
Did you have any luck with this?
Can't we just add .send
method to channels.py to support that?
... await self.socket.ws_connection.send(message)
Wouldn't that do the job?
I think it implemented in #68
Using this blog I implemented it myself from scratch and it works very well.
This issue is stale because it has been open for 365 days with no activity.
Documentation and examples show how to listen from messages from Phoenix, but sending to phoenix is not documented, nor is it clear that this is even possible.
As you can see Python inspect module does not show anything on channel chan1 that might look like a method for sending. Could you elucidate on if / how one can use this library for two-way comms? Thanks.