Trying to RPC to another node from a script, everything works when using "shortnames" but fails when using "longnames".
Where my local machine name is "Pandora", and after starting a detached node,
erl -detached -noshell -name 'node1@Pandora' -setcookie pandemic
Running this script with name_domain => shortnames,
#!/usr/bin/env escript
-mode(compile).
-define(THIS_NODE, 'testnode@Pandora').
-define(THAT_NODE, 'node1@Pandora').
show(R) -> io:format("~p~n", [R]).
main(_) ->
net_kernel:start(?THIS_NODE, #{name_domain => shortnames}),
erlang:set_cookie(?THAT_NODE, pandemic),
show( erl_epmd:names() ),
show( net_adm:names() ),
show( net_adm:ping(?THAT_NODE) ),
show( rpc:call(?THAT_NODE, erlang, time, []) ).
works correctly and produces this:
{ok,[{"node1",40965},{"testnode",35319}]}
{ok,[{"node1",40965},{"testnode",35319}]}
pong
{14,1,21}
However, when I change it to name_domain => longnames, to simulate working in a distributed environment):
net_kernel:start(?THIS_NODE, #{name_domain => longnames}),
The test fails with an error report:
=ERROR REPORT==== 6-Oct-2024::14:09:07.875238 ===
** System running to use fully qualified hostnames **
** Hostname Pandora is illegal **
Clearly, "Pandora" is not an FQDN so I attempted to solve this by creating a local Inets Configuration file called erl_inetrc and setting the local domain to that of my office router:
{domain, "myoffice.loc"}.
And did so in my test script, as well:
-define(THIS_NODE, '[email protected]').
-define(THAT_NODE, '[email protected]').
I then set the location of the file in the ERL_INETRC environment variable:
export ERL_INETRC="$(pwd)/erl_inetrc"
Sadly, this resulted in my test script freezing up at the net_adm:names() command. erl_epmd:names() worked, however, which is odd given net_adm:names is supposed to call erl_epmd:names.
Anybody have any idea why net_adm:names() freezes up?