Send a message to Phoenix channel from the server side


I’ve searched through the forum a bit without finding a satisfactory answer. I’m wondering if I can send a message to a Phoenix channel from the server side. My use case is a link-saving site that fetches the title of the bookmarked page in the background. This keeps the creation of a new bookmark fast, while still having useful info shown later.

Ideally, I’d like to notify a channel that a title for a URL is found and would like to update the UI to show the title. I don’t want to set up a bespoke SSE thing if I can use a channel for this.

I do have an alternative idea, which is not as nice, but would like to ask the community first.


Try YourApp.Endpoint.broadcast/3.


Thanks, I did figure that out.

However, now I’m running into an error saying that the pubsub server isn’t configured. This is in production.

** (ArgumentError) no :pubsub server configured at, please setup :pubsub in your config.^M
By default this looks like:
    config :my_app, MyApp.PubSub,
      pubsub: [name: MyApp.PubSub,
      adapter: Phoenix.PubSub.PG2]

    (phoenix) lib/phoenix/endpoint.ex:512: Phoenix.Endpoint.__pubsub_server__!/1

Can you show us what your config/prod.exs looks like?