[erlang-questions] Automatically reconnecting nodes when they come back online

Ignas Vyšniauskas <>
Mon Apr 29 08:41:50 CEST 2013


On 04/26/2013 07:00 PM, Scott Thoman wrote:
> My first two thoughts were: 1.  When the conductor node connects up
> the player nodes it would also spawn a process whose sole job is to
> periodically ping the other nodes to ensure they're connected.  Then
> when one goes down, those pings will just fail during that time but
> when the node comes back a ping will reconnect it to the other
> nodes. All this time, I'd be monitoring the node up/down messages. 2.
> I'd start by monitoring all the nodes as the conductor connects them
> and when receiving a node down message, spawn a process whose job it
> is to periodically ping only that node only until it comes back.

* you don't need a pinging mechanism, just use the existing
`net_kernel:monitor(true)` and handle the events.
* if you can afford a fixed node name for at least the "conductor" node,
then you can do something along the lines you described yourself --
should be trivial.
* otherwise you can try to hack things using `net_adm:world()` or
something like that for "dynamic" node discovery

Also, take a look at the `{sync_nodes_optional, NodeList}` parameter of
`kernel`.

--
Ignas


More information about the erlang-questions mailing list