incorporating dejaMoo: best of breed bull…

Erlang example error

Is it a Mac thing?

First bits

As I said in a previous post, I'm learning Erlang via Joe Armstrong's book: Programming Erlang. This post is probably only meaningful if you caught the same error - if not, and you read it to the end, I tip my hat to you!

The error

In chapter 10, Distributed Programming, I hit a small snag following along with the Name Server example.

As instructed I start the first of the two nodes:


$erl -sname gandalf
Erlang (BEAM) emulator version 5.5.4 [source]
 [async-threads:0] [kernel-poll:false]

Eshell V5.5.4  (abort with ^G)
(gandalf@loulou)1> kvs:start().
true
(gandalf@loulou)2>

And then the second:


$erl -sname bilbo
Erlang (BEAM) emulator version 5.5.4 [source]
 [async-threads:0] [kernel-poll:false]

Eshell V5.5.4  (abort with ^G)
(bilbo@loulou)1>

So far so good, although I notice the shell has picked up the computer name loulou instead of localhost (although it's not mentioned anywhere in /etc/hosts - someone might like to explain to me how this works).

Continuing on with the example:


(bilbo@loulou)1> rpc:call(gandalf@localhost, kvs, store, [weather, fine]).

=ERROR REPORT==== 27-Jun-2007::18:28:22 ===
Error in process <0.38.0> on node 'bilbo@loulou' with exit value: 
{badarg,[{erlang,list_to_existing_atom,["gandalf@loulou"]},
{dist_util,recv_challenge,1},
{dist_util,handshake_we_started,1}]}

{badrpc,nodedown}
(bilbo@loulou)2>

"Weird" says I, but having noticed the node registered as @loulou I figure it's worth a shot:


(bilbo@loulou)2> rpc:call(gandalf@loulou, kvs,store, [weather, fine]).
{badrpc,nodedown}
(bilbo@loulou)2>

Plenty of surfing the interwebs ensued, all to no avail. Eventually I tried:


$erl -sname gandalf@localhost
Erlang (BEAM) emulator version 5.5.4 [source]
 [async-threads:0] [kernel-poll:false]

Eshell V5.5.4  (abort with ^G)
(gandalf@localhost)1> kvs:start().
true
(gandalf@localhost)2>

%%

$erl -sname bilbo@localhost
Erlang (BEAM) emulator version 5.5.4 [source]
 [async-threads:0] [kernel-poll:false]

Eshell V5.5.4  (abort with ^G)
(bilbo@localhost)1>

Which changes the node name to look exactly like the example. Voila! The example works as expected:


(bilbo@localhost)1> rpc:call(gandalf@localhost, kvs,store, [weather, fine]).
true
(bilbo@localhost)2> rpc:call(gandalf@localhost, kvs, lookup, [weather]).
{ok,fine}

I only wish the weather were actually fine - it's pouring here in Melbourne!

PS: I'm sorry for the lame syntax highlighting - I'm too lazy to write a function to switch it off. Maybe later...

Comments (6) § Posted by in on
AddThis Social Bookmark Button

Comments 6

  1. anonymous wrote:

    Thanks for the post. I just encountered the same error on my MBP. I had an even more bizarre experience because my host name contains a dash (user-mac). So when it showed up in the initial error messages and I tried to send the rpc to gandalf@user-mac, Erlang thought I was trying to subtract numbers and started giving me weird badarith messages. Anyhow, issue solved.

    By the way, I tried going through the steps on a my linux box and after starting gandalf and bilbo and getting the error messages, things worked fine when I tried with gandalf@<realhostname>. go figure.

    Posted August 3, 2007 at 12:24 p.m.
  2. Cam wrote:

    That is weird! Are you doing anything exciting with Erlang, or just messing around?

    Posted August 9, 2007 at 4:22 p.m.
  3. Ben Ferrari wrote:

    Thanks for the hint, I had the same problem.

    Posted September 26, 2007 at 1:51 a.m.
  4. Cam wrote:

    No worries Ben :)

    Posted September 27, 2007 at 9:10 a.m.
  5. Jeff Pitman wrote:

    Thanks for this post. I was trying to get @localhost message passing working with the Getting Started guide on the Erlang website. It will not work as the default bind seems not to be on 0.0.0.0. Passing @localhost into -sname did the trick solving two problems: 1) having a node name of @user-macbookpro, and 2) trying to just use localhost to test distributed erlang on the same machine.

    Posted November 11, 2007 at 2:46 p.m.
  6. Cam wrote:

    Glad to help Jeff!

    Posted November 13, 2007 at 10:20 a.m.

Comments are now closed.

Tweet Tweet

Stuffs

Thanks for dropping in.

This is the personal website of Cam MacRae. Any opinions expressed here are my entirely own, and have jack to do with my employer.

It's the product of a little elbow grease, the news.ycombinator noprocrast feature, and a healthy dose of Django.

A Django site.

Tags

  1. D (1)
  2. SOA (1)
  3. ajax (2)
  4. apollo (1)
  5. architecture (1)
  6. bemused (1)
  7. blogs (2)
  8. carsales (1)
  9. collaboration (1)
  10. css (1)
  11. django (9)
  12. duels (1)
  13. email (1)
  14. erlang (3)
  15. findability (1)
  16. flex (3)
  17. folksonomies (1)
  18. funny (2)
  19. geek (20)
  20. google (3)
  21. innovation (1)
  22. iphone (1)
  23. javascript (4)
  24. jython (1)
  25. life (5)
  26. lighttpd (1)
  27. lisp (1)
  28. mac (1)
  29. macbook (1)
  30. marketing (1)
  31. open-source (1)
  32. oracle (2)
  33. python (6)
  34. rails (2)
  35. ruby (1)
  36. silverlight (1)
  37. skitch (1)
  38. startups (4)
  39. tech (21)
  40. twitter (1)
  41. usability (1)
  42. web20 (6)
  43. work (3)
  44. yui (2)
ten1000miles.com | Aussie Blogs |  Feed

Creative Commons License This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 Unported License.