Sending events to Phoenix Channel from Controller

Hi there,

Is it possible to send events to Phoenix channels that will be handled by handle_in/3 from say Phoenix controller instead of the JS client? Note that I can only get the topic of the channel, but not the channel pid.

I have tried out Endpoint.broadcast/3, but it doesn’t seems to fit my needs as Endpoint.broadcast/3 broadcast the message to subscribers instead of sending events that will trigger the handle_in/3 callback.


You can send a message to the channel process and handle it in handle_info/2 callback.
You can register the channel process with either Registry or phoenix pubsub to know its pid.