Well the default socket implementation is not meant to by vanilla websockets. You will have to implement your websocket by implementing the Phoenix.Socket.Transport behaviour.
It doesn’t seem to be a problem connecting with vanilla websocket (it works fine)? The also doesn’t really affect the issue, which is the case of auto-joining channels.
You’re connecting to the websocket endpoint, but unlikely to channels. Phoenix channels are not plain websockets, but a communication protocol, which can run on top of websockets, but also other transports.
So you need to implement that communication protocol for your plain websocket client. You can e.g. look at https://github.com/mobileoverlord/phoenix_client for a pure elixir implementation of connection to phoenix channels.
Hey Ben! Yes, I totally agree with you. The good news is that it’s just a simple JSON layer on-top of websockets; I was able to knock up join functionality etc with Python in just a few lines.
The issue here isn’t the actual communication bit, but getting the phx_join message to come from the server rather than the client.
I had a go with this but adapting it to the Socket. Alas it was just as you said, no luck. Thank you though, that’s easily the closest I’ve come to solving the issue!
I guess you would have to port the phoenix.js library to python. It is a very tiny client, simple and straightforward so it is worth a try and let it handle phx_join
Oh I definitely can port it to Python (I already kind-of have, in about 20 lines!).
The idea is just for the client to be able to subscribe to messages from the server (one-way).
I think I might try and write my own socket that hooks into PubSub in background, and delivers a simplified websocket interface. That’s tomorrow’s challenge