Reputation: 133
I know that two erlang nodes can communicate with each other, when they have the same cookie file. I have tested on my LAN network. But I want to know if such communication is possible when those two nodes are in two different network? If yes, how would we name those two nodes??
Upvotes: 0
Views: 715
Reputation: 41568
This works fine, as long as there is no firewall blocking communications. You'd need access to port 4369 for epmd, and to the ports chosen by the Erlang nodes. The range for the latter can be chosen using the inet_dist_listen_min
and inet_dist_listen_max
kernel parameters.
When starting the nodes, use -name
instead of -sname
to specify the name. The difference is that -name
uses fully qualified host names or IP addresses, while -sname
uses local hostnames.
You can give just a node name, e.g. -name mynode
, in which case the Erlang node will try to figure out the hostname to use, or you can explicitly give the hostname, e.g. -name [email protected]
or -name [email protected]
. If hostnames are used, all nodes need to be able to resolve the hostnames through /etc/hosts
or DNS.
So the command to start a node would look something like this:
erl -name [email protected] -kernel inet_dist_listen_min 42000 inet_dist_listen_max 43000
Upvotes: 2