Connecting erlang nodes

Tuesday, 17th May, 2011

In order to connect to each other, erlang nodes each need a name, they need to share a secret cookie, and if they’re to communicate over the internet, they need access to ports.

The secret cookie can be either set at runtime (as in the examples below), or in each user’s .erlang.cookie file.

For local connection

On the same machine or subnet, each node just needs a short name:

$ erl -sname chico -setcookie marx
...
(chico@localhost)1>

For internet connection

Each node must have the following ports available:

  • port 4369, used by epmd (the Erlang Port Mapper Daemon, not Erick and Parrish Making Dollars), must be open for both TCP and UDP (n.b.: this is a default).
  • another port or range of ports for the erlang nodes themselves. These nodes can be set at run time using the -kernel, inet_dist_listen_min and inet_dist_listen_max flags.

Each node must also use a full name, with either a domain or an IP address:

$ erl  -name chico@brothers.org  -setcookie longrandomstring  -kernel inet_dist_listen_min 9000  inet_dist_listen_max 9005
(chico@brothers.org)1>

Connecting

Erlang nodes are gregarious: as soon as nodes find out about each other, they connect. An easy way to say hello is “ping”:

(chico@localhost)1> nodes().
[]
(chico@localhost)2> net_adm:ping(groucho@localhost).
pong
(chico@localhost)3> nodes().                        
[groucho@localhost]
(chico@localhost)4> ^g
User switch command
 --> r groucho@localhost
 --> c
Eshell V5.7.2  (abort with ^G)
(groucho@localhost)1> 

You can skip the connection palaver by using the -remsh flag at startup:

$ erl -sname chico -setcookie marx -remsh groucho@localhost
...
(groucho@localhost)1>

etc

Introspection GUIs like AppMon and Pman can access any connected node (see the Nodes menu in the toolbar).

About these ads

One Response to “Connecting erlang nodes”


  1. […] you’re connected to the above node (see Connecting erlang nodes), you can run rb, the report browser. A little bit of set up is required. See this discussion on […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: