Re: 1-to-1 connections & possibly hidden nodes
Michael Truog <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <[email protected]> |
On 7/12/21 3:02 PM, Roberto Ostinelli wrote: > > What is the advantage over using a hidden node? Here below is the > output with one@ and two@ in a full cluster, while three@ has been > started with the -hidden option and has been connected only to one@: > > (*one*@dev.local)1> nodes(). > ['[email protected]'] > (*one*@dev.local)2> nodes(hidden). > ['[email protected]'] > (*one*@dev.local)3> register(shell, self()). > true > > (*two*@dev.local)1> nodes(). > ['[email protected]'] > (*two*@dev.local)2> nodes(hidden). > [] > > (*three*@dev.local)1> {shell, '[email protected]'} ! hello. > hello > > (*one*@dev.local)4> flush(). > Shell got hello > ok > > Hi Roberto, It is best if you have the kernel app 'dist_auto_connect' setting set to 'never' if you want to ensure each node connection is created programmatically (to avoid unintended node connections due to messages). The function net_kernel:connect_node/1 is creating a visible node connection, ensuring that your connection makes your node part of the fully connected set of visible nodes. If you used net_kernel:hidden_connect_node/1 a hidden node connection would be created and you will not get any additional node connections from that function call. However, net_kernel:hidden_connect_node/1 remains undocumented so it isn't clearly part of the public interface. CloudI (https://cloudi.org) uses it and it is the preferred function for connecting to an Erlang node from a script, so I would like to think the function isn't disappearing in the future. Best Regards, Michael