jejuro

jejuro

Book "Programming Phoenix 1.4" => failed to start child: RumblWeb.Presence

Hi,

I am reading “Programming Phoenix 1.4” and now on 265p.

To run sample codes of the book, I have input necessary commands into the terminal such as “mix deps.get”, “mix deps.update --all”, “cd assets && npm install force” commands in order. Most sample codes(such as umbrella projects) in the books show a similar error message as below. I could fix errors of some samples(such as “authentication”), but mostly not.

Error message

[warn] no configuration found for otp_app :rumbl_web and module RumblWeb.Endpoint
[info] Application rumbl_web exited: RumblWeb.Application.start(:normal, []) returned an error: shutdown: failed to start child: RumblWeb.Presence
    ** (EXIT) shutdown: failed to start child: Phoenix.Tracker
        ** (EXIT) shutdown: failed to start child: RumblWeb.Presence_shard0
            ** (EXIT) an exception was raised:
                ** (ArgumentError) argument error
                    (stdlib) :ets.lookup(RumblWeb.PubSub, :node_name)
                    (phoenix_pubsub) lib/phoenix/pubsub.ex:288: Phoenix.PubSub.call/3
                    (rumbl_web) lib/rumbl_web/channels/presence.ex:10: RumblWeb.Presence.init/1
                    (phoenix_pubsub) lib/phoenix/tracker/shard.ex:120: Phoenix.Tracker.Shard.init/1
                    (stdlib) gen_server.erl:374: :gen_server.init_it/2
                    (stdlib) gen_server.erl:342: :gen_server.init_it/6
                    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3

I am using macOS High Sierra, and I uploaded the error projects onto github.

https://github.com/team-jupeter/umbrella

The uploaded sample code has two small projects: “rumbl” and “rumbl_web”. The former works fine, and the latter shows the error message above.

Another sample code showing the same error message.

https://github.com/team-jupeter/rumbl_umbrella

I expect some help from the readers of the book. Always thank you.

PS> I guess the problem is in “config” as the message says.

[warn] no configuration found for otp_app :rumbl_web and module RumblWeb.Endpoint

But, I can’t figure it out to fix it.

PS 2>
After commenting out “RumblWeb.Presence” from the children list in “RumblWeb.Application.start()”, the sample projects works without “Presence” function. So, the issue is from “Presence” module. How to fix it work?

Marked As Solved

andreyuhai

andreyuhai

What this topic has made me realize is that, the ordering of the child applications in your application.ex matters. The whole time my children list was like this:

    children = [
      # Start the Telemetry supervisor
      # RumblWeb.Telemetry,
      # Start the Endpoint (http/https)
      RumblWeb.Endpoint,
      RumblWeb.Presence,
      {Phoenix.PubSub, name: RumblWeb.PubSub},
      # Start a worker by calling: RumblWeb.Worker.start_link(arg)
      # {RumblWeb.Worker, arg}
    ]

So if you’ve got Presence before PubSub you get the error below when you try mix phx.server:

╰─$ mix phx.server
==> rumbl_web
Compiling 1 file (.ex)
[info] Running RumblWeb.Endpoint with cowboy 2.9.0 at 0.0.0.0:4000 (http)
[info] Access RumblWeb.Endpoint at http://localhost:4000
[info] Application rumbl_web exited: RumblWeb.Application.start(:normal, []) returned an error: shutdown: failed to start child: RumblWeb.Presence
    ** (EXIT) shutdown: failed to start child: Phoenix.Presence.Tracker
        ** (EXIT) shutdown: failed to start child: RumblWeb.Presence_shard0
            ** (EXIT) an exception was raised:
                ** (ArgumentError) unknown registry: RumblWeb.PubSub
                    (elixir 1.11.4) lib/registry.ex:999: Registry.meta/2
                    (phoenix_pubsub 2.0.0) lib/phoenix/pubsub.ex:262: Phoenix.PubSub.node_name/1
                    (phoenix_pubsub 2.0.0) lib/phoenix/tracker/shard.ex:122: Phoenix.Tracker.Shard.init/1
                    (stdlib 3.14.2) gen_server.erl:417: :gen_server.init_it/2
                    (stdlib 3.14.2) gen_server.erl:385: :gen_server.init_it/6
                    (stdlib 3.14.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
** (Mix) Could not start application rumbl_web: RumblWeb.Application.start(:normal, []) returned an error: shutdown: failed to start child: RumblWeb.Presence
    ** (EXIT) shutdown: failed to start child: Phoenix.Presence.Tracker
        ** (EXIT) shutdown: failed to start child: RumblWeb.Presence_shard0
            ** (EXIT) an exception was raised:
                ** (ArgumentError) unknown registry: RumblWeb.PubSub
                    (elixir 1.11.4) lib/registry.ex:999: Registry.meta/2
                    (phoenix_pubsub 2.0.0) lib/phoenix/pubsub.ex:262: Phoenix.PubSub.node_name/1
                    (phoenix_pubsub 2.0.0) lib/phoenix/tracker/shard.ex:122: Phoenix.Tracker.Shard.init/1
                    (stdlib 3.14.2) gen_server.erl:417: :gen_server.init_it/2
                    (stdlib 3.14.2) gen_server.erl:385: :gen_server.init_it/6
                    (stdlib 3.14.2) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

So that’s probably because the applications are started in the order they are defined in the children list (please correct me if I am wrong as I am a newbie in Elixir/Phoenix).

Hence if you just swap the places of PubSub and Presence like below everything will be fine.

    children = [
      # Start the Telemetry supervisor
      # RumblWeb.Telemetry,
      # Start the Endpoint (http/https)
      RumblWeb.Endpoint,
      {Phoenix.PubSub, name: RumblWeb.PubSub},
      RumblWeb.Presence,
      # Start a worker by calling: RumblWeb.Worker.start_link(arg)
      # {RumblWeb.Worker, arg}
    ]

This information might be helpful for newcomers like me.

Also Liked

ityonemo

ityonemo

Your pubsub name in the config is Rumbl.PubSub and your presence module expects RumblWeb.PubSub

kabisote

kabisote

I was able to fix this by also adding Phoenix.PubSub with name as RumblWeb.PubSub as a child in apps/rumbl_web/application.ex

children = [
  RumblWeb.Endpoint,
  {Phoenix.PubSub, name: RumblWeb.PubSub},
  RumblWeb.Presence
]
asp

asp

Thanks for sharing this! It solved the issue for me too.

Where Next?

Popular in Questions Top

Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
mgjohns61585
Could someone help me? I’m making my first elixir program, number guessing game. I can’t figure out how to convert the user’s guess from ...
New
shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New

Other popular topics Top

axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 48342 226
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement