Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown registry: XXX.PubSub #144

Closed
michaelst opened this issue May 13, 2020 · 4 comments
Closed

unknown registry: XXX.PubSub #144

michaelst opened this issue May 13, 2020 · 4 comments

Comments

@michaelst
Copy link

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.

lib/registry.ex in Registry.info!/1 at line 1239
lib/registry.ex in Registry.register/3 at line 920
lib/phoenix/pubsub.ex in Phoenix.PubSub.subscribe/3 at line 117
lib/phoenix/channel/server.ex in Phoenix.Channel.Server.init_join/3 at line 401
lib/phoenix/channel/server.ex in Phoenix.Channel.Server.channel_join/4 at line 375
lib/phoenix/channel/server.ex in Phoenix.Channel.Server.handle_info/2 at line 299
gen_server.erl in :gen_server.try_dispatch/4 at line 637
gen_server.erl in :gen_server.handle_msg/6 at line 711
proc_lib.erl in :proc_lib.init_p_do_apply/3 at line 249
@chrismccord
Copy link
Member

What is the order of your supervision tree in application.ex?

@michaelst
Copy link
Author

michaelst commented May 13, 2020

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}
    ] 

@chrismccord
Copy link
Member

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 :)

@baxterjfinch
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants