无法获得两个Erlang节点进行通信 [英] Can't get two Erlang nodes to communicate
问题描述
无论我做什么,我都无法获得两个不同的节点进行通信.这可能是一个非常简单的问题.
No matter what I try, I can't get two different nodes to communicate. This is probably a very simple problem to solve.
我已经创建了文件.cookie.erlang,并将其放置到主目录中.然后,我打开一个终端窗口并键入以下命令:
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).
我总是得到"false"的结果,这意味着两个节点无法相互连接.我不明白我在这里想念什么...
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...
推荐答案
一定要确保"pc"是计算机的 actual 主机名.如果不是,请确保您正在使用.
Definitely make sure that 'pc' is the actual hostname of your machine. If it's not, make sure you're using that.
或者,因为您使用的是sname并且两个主机都在同一台计算机上,所以您可以使用 erl -sname user1
和 erl -sname user2
摆脱困境.
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
.
这篇关于无法获得两个Erlang节点进行通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!