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

Daniel Hallin Widgren daniel.widgren@REDACTED
Mon Jan 19 17:22:52 CET 2015


Hi,

Have you tried to use -name mynode@REDACTED instead of -sname mynode? I think you
need long name activated to talk to each other.

regards,
Daniel

2015-01-19 17:05 GMT+01:00 Harit Himanshu <harit.subscriptions@REDACTED>:

> 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150119/cb30f46d/attachment.htm>


More information about the erlang-questions mailing list