Can't get two Erlang nodes to communicate

限于喜欢 提交于 2021-01-27 17:12:54

问题


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...


回答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.




回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/13753741/cant-get-two-erlang-nodes-to-communicate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!