[erlang-questions] Problems when running distributed pingpong
Jiansen He
jiansenhe@REDACTED
Wed Oct 6 17:22:55 CEST 2010
Thank you for reply.
I tried to net_adm:ping/1 towards nodes on both machines.
When I start Erlang with -sname, fully qualified hostnames are rejected as
soon as net_adm:ping/1 is called. net_adm:ping('pong@REDACTED*')
returns pang if * represents another machine. I don't what else I can do
under -sname mode.
Since -name works no matter whether two machines are connected to the same
Ethernet, most of tests are run on this mode. The problem with -name mode
is finding out the valid hostname.
I also did following tests today.
(pong@REDACTED)1> net_adm:names().
{ok,[{"pong",49525}]}
(pong@REDACTED)2>
inet:gethostbyaddr('95.175.140.20').
{ok,{hostent,"dyn-95-175-140-20.chaledi.unite.inuknetworks.com",
["20.140.175.95.in-addr.arpa"],
inet,4,
[{95,175,140,20}]}}
(pong@REDACTED)3>
net_adm:ping('pong@REDACTED').
pang
(pong@REDACTED)4> net_adm:ping('
pong@REDACTED').
pong
Outside the Erlang
ping -c4 dyn-95-175-140-20.chaledi.unite.inuknetworks.com
PING dyn-95-175-140-20.chaledi.unite.inuknetworks.com (95.175.140.20): 56
data bytes
64 bytes from 95.175.140.20: icmp_seq=0 ttl=64 time=0.040 ms
64 bytes from 95.175.140.20: icmp_seq=1 ttl=64 time=0.121 ms
64 bytes from 95.175.140.20: icmp_seq=2 ttl=64 time=0.052 ms
64 bytes from 95.175.140.20: icmp_seq=3 ttl=64 time=0.123 ms
--- dyn-95-175-140-20.chaledi.unite.inuknetworks.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.040/0.084/0.123/0.038 ms
$ ping -c4 dyn-95-175-140-20.inuknetworks.com
ping: cannot resolve dyn-95-175-140-20.inuknetworks.com: Unknown host
$ ping -c4 "20.140.175.95.in-addr.arpa"
ping: cannot resolve 20.140.175.95.in-addr.arpa: Unknown host
In -name mode. I tried all 4 forms of hostname to ping both local machine
and remote machine. Only hostname with the form "dyn-95-175-140-*.
inuknetworks.com" works when I ping the same machine. None of them works
when I ping another machine.
I'm confused why I get so many hostnames for the same machine. All of them
works when I feed them to net_adm:dns_hostname/1. However, the only valid
hostname for net_adm:ping/1(dyn-95-175-140-20.inuknetworks.com) is different
from the only valid hostname for my local DNS (
dyn-95-175-140-20.chaledi.unite.inuknetworks.com). Will there be anther
possible hostname that I haven't found?
Jiansen
On Wed, Oct 6, 2010 at 8:22 AM, Bengt Kleberg <bengt.kleberg@REDACTED>wrote:
> 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
>
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
>
>
More information about the erlang-questions
mailing list