[erlang-questions] Problems when running distributed pingpong

Jiansen He <>
Wed Oct 6 00:29:42 CEST 2010


I'm new to Erlang.  I tried to run the distributed pingpong program which
could be found at http://www.erlang.org/doc/getting_started/conc_prog.html.
The program works well when I run it in two terminals on the same machine.
However, it doesn't work when I try to run it on two computers.  I posted my
testing result as follows.

on Machine1 (Mac OS X Version 10.6.4)
$ erl -sname pong
Erlang R14B (erts-5.8.1) [source] [smp:4:4] [rq:4] [async-threads:0] [hipe]

Eshell V5.8.1  (abort with ^G)

()1> tut17:start_pong().

On Machine2 (Windows 7)
>werl -sname ping

Erlang R14B (erts-5.8.1) [smp:2:2] [rq:2] [async-threads:0]

Eshell V5.8.1 (abort with ^G)

()1> tut17:start_ping('').

Nothing happened on both sides:(


To find the problem, I opened another terminal on both machines.

on Windows

Pinging with 32 bytes of data:
Reply from bytes=32 time=4ms TTL=64
Reply from bytes=32 time=1ms TTL=64
Reply from bytes=32 time=34ms TTL=64
Reply from bytes=32 time=10ms TTL=64

Ping statistics for
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 1ms, Maximum = 34ms, Average = 12ms

on Mac
dyn-95-175-140-5:~ $ ping -c4
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=128 time=1.491 ms
64 bytes from icmp_seq=1 ttl=128 time=0.388 ms
64 bytes from icmp_seq=2 ttl=128 time=0.399 ms
64 bytes from icmp_seq=3 ttl=128 time=0.811 ms

--- ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.388/0.772/1.491/0.449 ms

So, those two machines are connected to the same Ethernet and they can ping
each other.  I turned off the firewall but the program still doesn't work:(

To find more information about my network, I reopen the erlang system on Mac
with -name option
()3> net_adm:dns_hostname('
()4> net_adm:dns_hostname('

Then I open erlang system on Windows with -name option...

On Mac
()7> net_adm:dns_hostname('
()8> net_adm:dns_hostname('

It is clear that the erlang system could only recognize another host where
anthor erlang system is running.  And, more importantly, I get host names
that is known by my local DNS server.

On Mac
()8> erlang:get_cookie().

On windows
()1> erlang:get_cookie().

It shows that the magic cookies are set correctly on both machines.

on Mac
()9> pingpong:start_pong().
()10> net_adm:ping('
()11> net_adm:ping('
net_adm:localhost().                "dyn-95-175-140-3.inuknetworks.com"

It suggests that I should use hostname that has the form

on Windows
()2> net_adm:ping('

To summarize.  my two computers are connected to the same Ethernet.  The
only difference between two IP addresses is the last digit.  Firewalls are
closed on both machines.  Computers can ping each other from the outside of
Erlang system.  Inside the Erlang system, one machine could have at least 3
valid host names from DNS server's point of view.  However, only one of them
is valid for net_adm:ping/1, if Erlang is invoked with -name option.  An
Erlang system could detect another host where another Erlang system is
running.  Somehow, an Erlang system cannot communicate with an Erlang node
in another Erlang system.

Any suggestions?


More information about the erlang-questions mailing list