Search code examples
macoserlangerlang-otperlang-shell

Erlang Nodes See Each Other Only After Ping


I am running some erlang code on a Mac OSX, and I have this weird issue. My application is a multi node app where I have a single instance of a server that is shared between nodes (global).

The code works perfectly, except for one annoying thing: the different erlang nodes (I am running each node on a different terminal window) can only communicate with each other after ping!

So if on terminalA I am starting the server, and on terminalB I am running

erl>global:registered_names(). 

terminalB will return an empty list, unless, before starting the server on terminalA, I have ran a ping (from either one of the terminals).

For example, if I do this on either terminals before starting the server:

erl>net_adm:ping("terminalB"). 

then I start the server and from the second terminal I list the processes:

erl>global:registered_names(). 

This time I WILL see the registered process from the second terminal.

Is it possible that the mere net_adm:ping call does some kind of work (like DNS resolving or something like that) that allows the communication?


Solution

  • The nodes in a distributed Erlang system are loosely connected. The first time the name of another node is used, for example if spawn(Node,M,F,A) or net_adm:ping(Node) is called, a connection attempt to that node will be made.

    I find this in this link: http://www.erlang.org/doc/reference_manual/distributed.html#id85336

    I think you should read this article.