Note that there are some explanatory texts on larger screens.

plurals
  1. POWhy does net_kernel:monitor_nodes/2 not deliver nodeup/nodedown messages for sname nodes?
    primarykey
    data
    text
    <p>I start up a master node with a short name and get it running a process to monitor for node up and down messages. </p> <pre><code>&gt; erl -sname master -cookie monster Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace] Eshell V5.9.3 (abort with ^G) (master@pencil)1&gt; c("/tmp/monitor.erl"). {ok,monitor} (master@pencil)2&gt; Pid = monitor:start(). &lt;0.44.0&gt; (master@pencil)3&gt; Pid ! running. RECV :: running running (master@pencil)4&gt; net_adm:names(). {ok,[{"master",52564}]} </code></pre> <p>At this point only the <code>master</code> node is running. I startup the second node on the same machine: </p> <pre><code>&gt; erl -sname client -cookie monster Erlang R15B03 (erts-5.9.3) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace] Eshell V5.9.3 (abort with ^G) (client@pencil)1&gt; </code></pre> <p>and wait for a minute, just incase I'm reading the docs wrong and there's a complication with the net tickrate. Nothing, so on master I force the connection: </p> <pre><code>(master@pencil)5&gt; net_adm:names(). {ok,[{"master",52564},{"client",52579}]} (master@pencil)6&gt; </code></pre> <p>and nothing from my little monitor process. Now, if I do the <em>same</em> thing but use long names--that is <code>-name</code>--this works just fine. I'm surprised, though, as the <code>net_kernel</code> docs don't mention that. What's the deal? </p> <hr> <p>Here's the <code>monitor.erl</code> referenced above: </p> <pre><code>-module(monitor). -export([start/0]). start() -&gt; spawn_link(fun init_loop/0). %%%=================================================================== %%% Internal Functions %%%=================================================================== init_loop() -&gt; net_kernel:monitor_nodes(true, []), loop(). loop() -&gt; receive Msg -&gt; io:format(user, "RECV :: ~p~n", [Msg]) end, loop(). </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload