[erlang-questions] net_kernel:start() "the name seems to be in use by another Erlang node"
zxq9@REDACTED
zxq9@REDACTED
Mon Jan 29 09:57:09 CET 2018
On 2018年1月28日日曜日 15時51分07秒 JST Mark Sebald wrote:
> I am using "net_kernel:start()", to start multiple nodes of the same
> application, on the same host. Each time I start a node, I don't know how
> many other nodes were already started, so my thinking was to add an index
> number to the node name, and if start() returns: "{already_started, pid()}"
> I will increment the index on the node name, and call start() again.
>
> Instead, when I try to start a second node of the same name I get this:
>
> 14:14:29.425 [info] Protocol 'inet_tcp': the name my_node01@REDACTED seems
> to be in use by another Erlang node
> 14:14:29.425 [error] CRASH REPORT Process <0.109.0> with 0 neighbours
> exited with reason: {error,badarg} in gen_server:init_it/6 line 349
>
> and an error tuple is returned
>
> This seems like an Erlang bug, since the info log message indicates that
> the situation is well in hand, but then we get a crash. Is there a better
> way to start multiple nodes? Are there any conditions where start() will
> return "already_started"?
I've not messed with this in a while, but I do recall being able to do dynamic
start names like this. I don't have a sample of the code that did it for me,
though.
In the shell, however, the following worked.
Node 1:
Eshell V9.2 (abort with ^G)
1> net_kernel:start([foo, longnames]).
{ok,<0.66.0>}
(foo@REDACTED)2>
Node 2:
Eshell V9.2 (abort with ^G)
1> Start =
1> fun(Name1, Name2) ->
1> case net_kernel:start([Name1, longnames]) of
1> {ok, Pid} ->
1> {ok, Pid};
1> {error, Reason} ->
1> ok = io:format("Failed with ~tp~nTrying ~tp~n", [Reason, Name2]),
1> net_kernel:start([Name2, longnames])
1> end
1> end.
#Fun<erl_eval.12.99386804>
2> Start(foo, bar).
Failed with {{shutdown,
{failed_to_start_child,net_kernel,{'EXIT',nodistribution}}},
{child,undefined,net_sup_dynamic,
{erl_distribution,start_link,[[foo,longnames],false]},
permanent,1000,supervisor,
[erl_distribution]}}
Trying bar
=INFO REPORT==== 29-Jan-2018::17:48:11 ===
Protocol 'inet_tcp': the name foo@REDACTED seems to be in use by another Erlang node
{ok,<0.71.0>}
(bar@REDACTED)3>
The info message from SASL still pops up, but it isn't crashing anything,
just returning the error tuple as expected. I'm not sure what else would
be going on in your case. I know there are a few tricky EPMD issues, I just
never seem to run into them.
-Craig
More information about the erlang-questions
mailing list