[erlang-questions] Connection of nodes with different cookie

Zhongzheng Liu liuzhongzheng2012@REDACTED
Thu Apr 7 05:47:19 CEST 2016

Hi mail list:

I started two nodes in my pc:

    erl -name 'a@REDACTED' -setcookie aa
    erl -name 'b@REDACTED' -setcookie bb

If I run erlang:set_cookie('b@REDACTED', bb) in node a, a and b is
connectable with each other.

But if i run both erlang:set_cookie('b@REDACTED', bb) in node a and
 erlang:set_cookie('a@REDACTED', aa) in node b before i connect a and b,
the connection will fail.

I found the code in dist_util.erl:

%% Get the cookies for a node from auth
get_cookies(Node) ->
    case auth:get_cookie(Node) of
X when is_atom(X) ->
% {Y,Z} when is_atom(Y), is_atom(Z) ->
%     {Y,Z};
% _ ->
%     erlang:error("Corrupt cookie database")

This function should return {MyCookie,HisCookie} as the other code written
in this module, but currently it just simply make MyCookie and HisCookie
the same one.

I guess this design is for the convenience when you connecting a node
having different cookie. In general you are not able to run
erlang:set_cookie/2 before you connect it, you can only change your own
cookie to connect other node.

But I think connection should also success if cookie is set by
erlang:set_cookie/2 in both side for each other.

Do you think so?

Liu Zhongzheng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20160407/c467c0c3/attachment.htm>

More information about the erlang-questions mailing list