I'm working on an application that is required to be clustered on multiple machines, so I have to configure VertxOptions object by setting the cluster host and port on each node (machine), but I came across different methods for setting hosts and ports: setClusterhost/port, setPublicClusterHost/port. What is the difference?
1 Answers
The clusterHost
property tells Vert.x which host it should bind the socket to. The clusterPublicHost
how other nodes should connect. By default the values are the same, but sometimes because of proxies you need a way to make them different.
This is explained in the Javadoc:
Set the public facing hostname to be used for clustering. Sometimes, e.g. when running on certain clouds, the local address the server listens on for clustering is not the same address that other nodes connect to it at, as the OS / cloud infrastructure does some kind of proxying. If this is the case you can specify a public hostname which is different from the hostname the server listens at. The default value is null which means use the same as the cluster hostname.

- 8,591
- 1
- 17
- 27
-
Ok, if this is the case and we set the public cluster host a different IP address than the cluster host how would this different IP be used? Currently I'm setting the cluster host on each machine to the same machine's IP, if we give another value to the public cluster host this value would be used by the cluster manager or it should be used in a different way? – Mohamed Ibrahim Elsayed Feb 28 '18 at 11:59
-
@Mis94 the `clusterPublicHost` is the only thing publish by the cluster manager to other nodes. By defaults, it is the same as `clusterHost`. Other nodes connect to the `clusterPublicHost` – tsegismont Feb 28 '18 at 13:12
-
This is theory. In practice quite a few combinations simply do not work. Where is a proper documentation example that prooves that things work as documented? – Wolfgang Fahl Mar 07 '20 at 14:53