Broadcasting to Phoenix Channel without Phoenix?

handle_out is being called because It’s not respecting the channel subscriber fastlanining, but without seeing your code it’s hard to say why that is. In any case, instead of trying to build cheat by building the Phoenix.Socket.Broadcast, I would have the external app broadcast “raw” messages over pubsub that your phoenix app subscribes to. You could have the channel subscribe to the topic and forward the message in handle_info, or you can have server(s) in your app subscribing to external topics/events, and then relaying them to channels via MyApp.Endpoint.broadcast. This way you aren’t coupling the external app to your channel layer directly. This also gives you a place to do any necessary data munging from the external data to the client representation.

4 Likes