One can init a Elixir node by iex using:
iex --sname [email protected] --cookie foo
And then another one can connect this node in REPL using:
Node.connect(:"[email protected]")
It seems the connection is over TCP protocol. However, I didn't find a parameter in document to specify which port is used. Does anyone have any ideas about this?
Connecting nodes is handled by the Erlang Port Mapping Daemon (epmd) which runs by default on port 4369. From the documentation:
A different port can be specified to allow several instances of epmd, representing independent clusters of nodes, to co-exist on the same host. All nodes in a cluster must use the same epmd port number.
The actual node opens a random(?) port and announces this along with its sname
to the local epmd
. When you now connect to '[email protected]'
, your Erlang VM will ask the remote epmd
running on 10.99.1.50
on port 4369 for information on 'node1'
. It will answer with the actual port number to which your process then connects directly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With