Autoreconnect nodes

BEAM nodes connect to each other when a message is sent between them. Due to this, disconnected nodes automatically try to reconnect as long as messages are still pending for the disconnected node, there is no additional action needed from your side.

The best practice for keeping two nodes connected is to have TCP bonding through different NICs at the OS level.

Regarding Node.monitor : the docs say to read erlang:monitor_node/1. monitor_node/1 document says that the process calling this function would be sent a {:nodedown, node} message when the node goes down. You either have a specific receive clause for this message or handle it in GenServer.handle_info/2.

In general you monitor a node only if you have something specific you need to do should that specific node go down (e.g. resource clean-up). Typically it isn’t common to require monitoring a node.

4 Likes