2

No matter what I try, I can't get two different nodes to communicate. This is probably a very simple problem to solve.

I have created the file .cookie.erlang and I've placed it into my home directory. Then I open a terminal window and type the following commands:

erl -sname user1@pc
erlang:set_cookie(node(),cookie).

In another terminal window I type:

erl -sname user2@pc
erlang:set_cookie(node(),cookie).

Now if I type the following command in the first terminal window:

net_adm:ping(user2@pc).

I always get "false" as result, meaning that the two nodes were not able to connect to each other. I don't understand what I am missing here...

user1301428
  • 1,743
  • 3
  • 25
  • 57

3 Answers3

1

Definitely make sure that 'pc' is the actual hostname of your machine. If it's not, make sure you're using that.

Alternatively, since you're using sname and both hosts are on the same machine, you could get away with doing erl -sname user1 and erl -sname user2.

chops
  • 2,572
  • 1
  • 16
  • 25
  • Your answer solved my problem, thanks :) However, isn't it possible to use a hostname that is different from the one of my machine? – user1301428 Dec 06 '12 at 23:02
  • You can indeed, however you need to make sure that whatever you put after the @ resolves to the proper machine. For example, you can do an IP address (user1@127.0.0.1) or a hostname you put into the hosts file (user1@whatever_host_from_hosts_file_that_resolves_to_me). Erlang just needs to be able to find the target host. – chops Dec 07 '12 at 16:06
0

This is a DNS problem, please see here, which the answer of a similar problem

Community
  • 1
  • 1
tianxiao
  • 13
  • 3
0

Yes, it looks mostly a DNS issue. You should update it in /etc/hosts if you are on a Unix based OS, if it is on the same machine you can always use localhost that will be reachable:

erl -sname a@localhost -cookie aloha

Then in a separate terminal:

erl -sname b@localhost -cookie aloha

With that you should be able to communicate nodes just fine.

codeadict
  • 2,643
  • 1
  • 15
  • 11