How to set env.sh.eex for DNSCluster?

Tried DNSCluster recently, but it did not connect my 2 nodes in LAN automatically. Used ‘DNS_CLUSTER_QUERY’ as keyword to google search the Internet, and read all I got, my DNSCluster still cannot connect my 2 nodes in LAN automatically.

Please help:

Here is part of my env.sh.eex of node1:

export APP_NAME="myapp"
export DNS_CLUSTER_QUERY="${APP_NAME}.internal"
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE="${APP_NAME}@192.168.1.1" # for node1

And here is part of my env.sh.eex of node2:

export APP_NAME="myapp"
export DNS_CLUSTER_QUERY="${APP_NAME}.internal"
export RELEASE_DISTRIBUTION=name
export RELEASE_NODE="${APP_NAME}@192.168.1.2" # for node2

After run
_build/prod/rel/myapp/bin/myapp start_iex
on each node, the output of Node.list() is always [] no matter how long I waited.

But if I did Node.connect(:"myapp@192.168.1.2") in node1, Node.list() will have another node name in the output, and the Phoenix PubSub works across these 2 nodes.

What did I miss? Why DNSCluster did not connect my 2 nodes automatically? Please help.

edit:

make sure myapp.internal resolve A record dns both ip 192.168.1.2, 192.168.1.1

# Example, check using iex
iex(app@172.19.0.5)1> :inet_res.lookup(~c"chat.internal", :in, :a)
[{172, 19, 0, 5}]
iex(app@172.19.0.5)2>
1 Like

Thanks a lot @sucipto , you save my life!

1 Like