Closed michaelst closed 4 years ago
What is the order of your supervision tree in application.ex?
Ignore the second piece of the tuple on each, we do filtering on env.
Does pubsub need to be before endpoint?
[
{Repo, :all},
{Endpoint, :all},
...
{{Phoenix.PubSub,
[
name: ZB.PubSub,
adapter: Phoenix.PubSub.Redis,
url: Application.get_env(:redix, :url),
node_name: System.get_env("HOSTNAME", "local")
]}, :all}
]
Yes, you need to start PubSub before your endpoint, as you can race the pubsub server by servicing requests/channels that use pubsub before it's up :)
I am having a compilation error similar to this and my PubSub is started before Endpoint.
I have three apps under lib. PubSub is added to the application.ex under the main app called metadata.
children = [
Metadata.Repo,
{Phoenix.PubSub, name: :metadata_pubsub},
MetadataWeb.Endpoint,
MetadataWeb.Telemetry
]
I then add this to a controller under the metadata_web app which inserts something in my database
PubSub.broadcast :metadata_pubsub, "item", {:item_created, %{test: item}}
I have a route in metadata_web that points to a live_dashboard app:
scope "/live", MetadataWeb do
pipe_through :browser
live_dashboard "/", metrics: MetadataWeb.Telemetry
end
and under lib/live_dashboard/live/item_live.ex
I do the following:
defmodule Phoenix.LiveDashboard.ItemLive do
... stuff ...
alias Phoenix.PubSub
PubSub.subscribe :mythical_pubsub, "dgood"
but then I get this error:
== Compilation error in file lib/live_dashboard/live/item_live.ex ==
** (ArgumentError) unknown registry: :metadata_pubsub
(elixir 1.10.2) lib/registry.ex:1239: Registry.info!/1
(elixir 1.10.2) lib/registry.ex:920: Registry.register/3
(phoenix_pubsub 2.0.0) lib/phoenix/pubsub.ex:117: Phoenix.PubSub.subscribe/3
lib/live_dashboard/live/item_live.ex:12: (module)
(stdlib 3.11.2) erl_eval.erl:680: :erl_eval.do_apply/6
(elixir 1.10.2) lib/kernel/parallel_compiler.ex:304: anonymous fn/4 in Kernel.ParallelCompiler.spawn_workers/7
I'm new to phoenix and elixir in general so let me know if this project layout doesn't make sense or if I'm doing something obviously incorrect.
Thank you!
With the update to v2 I am starting to see this error. It appears that I have everything configured correctly as it is still working, but just getting this error occasionally.