Phoenix Channel - question on broadcast behavior on cluster

Hi,

I am learning about Phoenix Channel and have question on behavior of broadcast which not as I expected.

Environment: Windows 10, Phoenix 1.4.17, Erlang 22, Elixir 1.12

Nodes:
server@127.0.01, listening on port 4000
remote@127.0.0.1, listening on port 4001

Client:
client1 - wscat connects to server@127.0.0.1 on port 4000, then subscribe to “ping” topic.
client2 - wscat connects to remote@127.0.0.1 on port 4001, then subscribe to “ping” topic.

And here is my doubt, when I broadcast on server@127.0.0.1, only client1 receives the message.
When I broadcast on remote@127.0.0.1, only client2 receives the message.

I need help on what is exactly the correct behavior?

Thanks

Have you connected the two nodes? They need to be connected before they can chat with each other.

iex(remote@127.0.0.1)3> Node.connect(:"server@127.0.0.1")

That’s all it needs. Thanks.

How to make them connected automatically on startup?

You can look at the libcluster library as one way to do that

Many thanks for giving the hint.