Node.start function doesn't work properly

Environment

  • Elixir & Erlang versions (elixir --version):
    Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Elixir 1.5.1

  • Operating system: Ubuntu 16.04 LTS

Current behavior

When i try use Node.start function from iex mode nothing happens and error appears.

Node.start “user@comp” # Node.start “user”

{:error,
 {{:shutdown, {:failed_to_start_child, :net_kernel, {:EXIT, :nodistribution}}},
  {:child, :undefined, :net_sup_dynamic,
   {:erl_distribution, :start_link,
    [["user@lanycrost", :longnames, 15000], false]}, :permanent, 1000,
   :supervisor, [:erl_distribution]}}}

Thanks!

You did not start with either --name or a --sname option, therefor node distribution is disabled. :slight_smile:

1 Like

I think problem is not because of this. See here:

$ iex --name user@lanycrost                                                                                                                     ✓  3454  18:49:10 
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(user@lanycrost)1> Node.start "name"
{:error,
 {{:already_started, #PID<0.46.0>},
  {:child, :undefined, :net_sup_dynamic,
   {:erl_distribution, :start_link, [["name", :longnames, 15000], false]},
   :permanent, 1000, :supervisor, [:erl_distribution]}}}
iex(user@lanycrost)2> 
iex --sname user                                                                                                                              ✓  3454  18:50:28 
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false]

Interactive Elixir (1.5.1) - press Ctrl+C to exit (type h() ENTER for help)
iex(user@lanycrost)1> Node.start "name"
{:error,
 {{:already_started, #PID<0.46.0>},
  {:child, :undefined, :net_sup_dynamic,
   {:erl_distribution, :start_link, [["name", :longnames, 15000], false]},
   :permanent, 1000, :supervisor, [:erl_distribution]}}}
iex(user@lanycrost)2> 

Also I opened issue for this problem. There is possibility that someone else encountered this problem too. :grin:

And that problem is because you already have distribution started and already connected to an epmd instance so you cannot start ‘another’ copy of it. ^.^

OK… Then how to use Node.start from interactive mod? :grin: :grin: :grin:

As @josevalim already pointed out in the isseu:

 $ iex
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe]

Interactive Elixir (1.5.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Node.start :foo, :shortnames

17:28:26.829 [info]  Protocol 'inet_tcp': register/listen error: econnrefused

{:error,
 {{:shutdown, {:failed_to_start_child, :net_kernel, {:EXIT, :nodistribution}}},
  {:child, :undefined, :net_sup_dynamic,
   {:erl_distribution, :start_link, [[:foo, :shortnames, 15000], false]},
   :permanent, 1000, :supervisor, [:erl_distribution]}}}
iex(2)>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C%                                                                                                                    $ epmd -daemon
$ iex
Erlang/OTP 20 [erts-9.0] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe]

Interactive Elixir (1.5.0) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> Node.start :foo, :shortnames
{:ok, #PID<0.87.0>}
iex(foo@funtoo-tuxedo)2>
BREAK: (a)bort (c)ontinue (p)roc info (i)nfo (l)oaded
       (v)ersion (k)ill (D)b-tables (d)istribution
^C%

Starting epmd manually will do! Also you’ll need to use atoms as names

4 Likes

Ohh… Thanks))