[erlang-questions] Problems when running distributed pingpong

Bengt Kleberg bengt.kleberg@REDACTED
Wed Oct 6 09:22:48 CEST 2010


Greetings,

I see that you have tried to net_adm:ping/1 yourself (the node you are
on).
Have you tried the same command towards the other node? Preferably with
all the 3 different addresses, both when the nodes have been started
with -name and -sname.


bengt

On Wed, 2010-10-06 at 00:29 +0200, Jiansen He wrote:
> Hi,
> 
> 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]
> [kernel-poll:false]
> 
> Eshell V5.8.1  (abort with ^G)
> (pong@REDACTED)1>
> 
> (pong@REDACTED)1> tut17:start_pong().
> true
> 
> 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)
> (ping@REDACTED)1>
> 
> (ping@REDACTED)1> tut17:start_ping('pong@REDACTED').
> <0.39.0>
> (ping@REDACTED)2>
> 
> 
> Nothing happened on both sides:(
> 
> =========
> 
> To find the problem, I opened another terminal on both machines.
> 
> on Windows
> ~>ping 95.175.140.5
> 
> Pinging 95.175.140.5 with 32 bytes of data:
> Reply from 95.175.140.5: bytes=32 time=4ms TTL=64
> Reply from 95.175.140.5: bytes=32 time=1ms TTL=64
> Reply from 95.175.140.5: bytes=32 time=34ms TTL=64
> Reply from 95.175.140.5: bytes=32 time=10ms TTL=64
> 
> Ping statistics for 95.175.140.5:
>     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 95.175.140.3
> PING 95.175.140.3 (95.175.140.3): 56 data bytes
> 64 bytes from 95.175.140.3: icmp_seq=0 ttl=128 time=1.491 ms
> 64 bytes from 95.175.140.3: icmp_seq=1 ttl=128 time=0.388 ms
> 64 bytes from 95.175.140.3: icmp_seq=2 ttl=128 time=0.399 ms
> 64 bytes from 95.175.140.3: icmp_seq=3 ttl=128 time=0.811 ms
> 
> --- 95.175.140.3 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
> (pong@REDACTED)1>
> inet:gethostbyaddr('95.175.140.5').
> {ok,{hostent,"dyn-95-175-140-5.chaledi.unite.inuknetworks.com",
>              ["5.140.175.95.in-addr.arpa"],
>              inet,4,
>              [{95,175,140,5}]}}
> (pong@REDACTED)2>
> net_adm:dns_hostname('dyn-95-175-140-5').
> {ok,"dyn-95-175-140-5"}
> (pong@REDACTED)3> net_adm:dns_hostname('
> dyn-95-175-140-5.inuknetworks.com').
> {ok,"dyn-95-175-140-5.inuknetworks.com"}
> (pong@REDACTED)4> net_adm:dns_hostname('
> dyn-95-175-140-3.inuknetworks.com').
> {error,'dyn-95-175-140-3.inuknetworks.com'}
> 
> Then I open erlang system on Windows with -name option...
> 
> On Mac
> (pong@REDACTED)5>
> inet:gethostbyaddr('95.175.140.3').
> {ok,{hostent,"dyn-95-175-140-3.chaledi.unite.inuknetworks.com",
>              ["3.140.175.95.in-addr.arpa"],
>              inet,4,
>              [{95,175,140,3}]}}
> (pong@REDACTED)6>
> net_adm:dns_hostname('dyn-95-175-140-3').
> {ok,"dyn-95-175-140-19"}
> (pong@REDACTED)7> net_adm:dns_hostname('
> dyn-95-175-140-3.inuknetworks.com').
> {ok,"dyn-95-175-140-3.inuknetworks.com"}
> (pong@REDACTED)8> net_adm:dns_hostname('
> dyn-95-175-140-3.chaledi.unite.inuknetworks.com').
> {ok,"dyn-95-175-140-3.chaledi.unite.inuknetworks.com"}
> 
> 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
> (pong@REDACTED)8> erlang:get_cookie().
> 'erlang_cookie'
> 
> On windows
> (ping@REDACTED)1> erlang:get_cookie().
> 'erlang_cookie'
> 
> It shows that the magic cookies are set correctly on both machines.
> 
> on Mac
> (pong@REDACTED)9> pingpong:start_pong().
> true
> (pong@REDACTED)10> net_adm:ping('
> pong@REDACTED').
> pong
> (pong@REDACTED)11> net_adm:ping('
> pong@REDACTED').
> pang
> (pong@REDACTED)12>
> net_adm:localhost().                "dyn-95-175-140-3.inuknetworks.com"
> 
> It suggests that I should use hostname that has the form
> 'nodeName@REDACTED*.inuknetworks.com'
> 
> on Windows
> (ping@REDACTED)2> net_adm:ping('
> pong@REDACTED').
> pang
> 
> 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?
> 
> 
> Jiansen



More information about the erlang-questions mailing list