[erlang-questions] Erlang Nodes can't communicate with each other

Harit Himanshu harit.subscriptions@REDACTED
Mon Jan 19 17:05:31 CET 2015


Hi

I am learning Distributed programming and in order to work through it, I
started 2 docker containers using images provided by Mark Nijhof (
https://github.com/MarkNijhof/erlang_docker)

So now when I start my docker containers (on same Macbook), I observe that
they are not able to talk to each other

*Server*

root@REDACTED:/code# erl -sname gru -setcookie abc

Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10]
[hipe] [kernel-poll:false]


Eshell V6.0  (abort with ^G)

(gru@REDACTED)1> kvs:start().

true

(gru@REDACTED)2>

*Minion*

➜  erlang_docker git:(master) docker run -t -i erlang-build-box /bin/bash

root@REDACTED:/# mkdir code

root@REDACTED:/# cd code

root@REDACTED:/code# vi kvs.erl

root@REDACTED:/code# erl -sname minion1 -setcookie abc

Erlang/OTP 17 [erts-6.0] [source] [64-bit] [smp:8:8] [async-threads:10]
[hipe] [kernel-poll:false]


Eshell V6.0  (abort with ^G)

(minion1@REDACTED)1> rpc:call(gru@REDACTED, kvs, store, [weather,
fine]).

{badrpc,nodedown}

(minion1@REDACTED)2> rpc:call(gru@REDACTED, kvs, store, [weather,
fine]).

{badrpc,nodedown}

(minion1@REDACTED)3> c(kvs).

{ok,kvs}

(minion1@REDACTED)4> rpc:call(gru@REDACTED, kvs, store, [weather,
fine]).

{badrpc,nodedown}

(minion1@REDACTED)5>



My code looks like following and it works correctly when both server and
minion are on same node

-module(kvs).
-author("harith").

%% API
-export([start/0, store/2, lookup/1]).

start() ->
  register(kvs, spawn(fun() -> loop() end)).

store(Key, Value) ->
  rpc({store, Key, Value}).

lookup(Key) ->
  rpc({lookup, Key}).

rpc(Q) ->
  kvs ! {self(), Q},
  receive
    {kvs, Reply} ->
      Reply
  end.

loop() ->
  receive
    {From, {store, Key, Value}} ->
      put(Key, {ok, Value}),
      From ! {kvs, true},
      loop();
    {From, {lookup, Key}} ->
      From ! {kvs, get(Key)},
      loop()
  end.


What am I missing here?

Thanks
+ Harit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150119/7bb8af7e/attachment.htm>


More information about the erlang-questions mailing list