How to control cluster topology for pub/sub project

Hi everyone,
I am starting work on a project where I have 1…50 devices that collect data, share the data internally using pub/sub, but also need to share up to a master device. Each node connects to the master at startup. Since the devices and the master subscribe to the same pub/sub name and topic, the data gets to the master without any further work. What I didn’t expect is that when d1 connects to M and d2 connects to M, d1 would connect to d2. I don’t want these sharing data. I know that I could fix the problem by having the topics be unique to each node, but that feels like a kludge.

The question is: Can I construct a cluster where each of the nodes connect up to the master but don’t connect to each other? Can libcluster or possibly peerage help accomplish this?

Thanks in advance for any help.

Another option is to forgo Erlang distribution and connect then with a channels client, e.g. phx_gen_socket or Slipstream.

After some digging, the solution is pretty simple

Add the following to the startup line: --erl “-connect_all false”

This makes node connections transitive, i.e. what I detailed above. See Erlang -- kernel

The Erlang manual says this flag is deprecated, but the replacement flag didn’t work for me. I haven’t tried to figure out the issue but this should point anyone else with this issue toward

1 Like