[erlang-questions] global:registered_names() returns []

Adrian Balij <>
Wed Oct 22 21:48:01 CEST 2008


Thank you Andrew, that did work and I was able to see the registered names
on both nodes.

It is odd how in books such as Programming Erlang by Joe and the videos by
Kevin Smith never mention the need to use net_kernel:connect and somehow
their examples seem to work. Maybe I missed something or my lack of
experience cannot answer this odd scenario.

Although your solution worked, I ran into another problem. Both nodes can
see the registered names: [account_monitor]

However, when I call gen_server:start_link for the first time, the name does
not get registered! However any subsequent calls (without terminating the
node) causes the process to register!!

On top of that, when I call gen_server:call(account_monitor, getOnlineUsers)
, I get the error:

*exception exit: {noproc, {gen_server, call,[account_monitor,
getOnlineUsers]}}

Any have any ideas why?

Sincerely,

Adrian Balij
Software Engineer
Musket/Melburn Group


-----Original Message-----
From: Andrew Stone [mailto:] 
Sent: October 22, 2008 1:05 PM
To: 
Subject: Re: [erlang-questions] global:registered_names() returns []

Adrian,

I think you want to call net_kernel:connect right before you call
global:sync. That will actually connect the two nodes. Then global:sync will
synch the names on each node.

-Andrew



----- Original Message ----
From: "" <>
To: 
Sent: Tuesday, October 21, 2008 4:24:39 PM
Subject: [erlang-questions] global:registered_names() returns []

Hello everyone,

I am fairly new to Erlang and I have been trying to setup a gen_server so
that other nodes can communicate with it. However, on the client nodes,
every time I call global:registered_names(), it returns []. The odd thing
is on the server node, calling global:registered_names() returns
[account_monitor].

I am running two consoles on the same computer using the following commands:

erl -sname  -setcookie Test

erl -sname  -setcookie Test

Both consoles can ping each other.

My start function is:

% Initialize routine
start_link() -> gen_server:start_link({global, ?MODULE}, ?MODULE, [], []).

where ?MODULE = account_monitor.

I tried calling net_adm:world() and global:sync() and no luck at all!

The gen_server works fine (and by fine, I mean calling
gen_server:call(...)) when I start it locally (start_link({local, ?MODULE}
....).

Any help or suggestions would be extremely helpful at this point!

Additional info:
- OS: Leopard 10.5
- Erang bin: Sep 3, 2008

Thank you for your time,

Adrian Balij


_______________________________________________
erlang-questions mailing list

http://www.erlang.org/mailman/listinfo/erlang-questions






More information about the erlang-questions mailing list