Specification of the protocol used by Phoenix channels

I’m certainly with you, that some more detailed specification would be nice.

What you can find in the js file are the handful of channel-specific events you could receive besides the custom user-land events:

const CHANNEL_EVENTS = {
  close: "phx_close",
  error: "phx_error",
  join: "phx_join",
  reply: "phx_reply",
  leave: "phx_leave"
}

The other part a client needs to be aware of is in which format messages are sent by the used transport.

https://hexdocs.pm/phoenix/Phoenix.Socket.Transport.html#content

E.g. the built in transports use basically a simple json blob for messages:

So the channel -> transport interface is documented and the websocket/longpolling transport -> client is using json in a particular format.

So what I miss the most is some descriptions for the above listed channel events and when they’re sent/shall be sent, some description about how to handle the different refs in messages and how to handle presence lists/diffs.

1 Like