Hi,
I have a cluster with three nodes on docker.
MasterNode: 0.0.0.0:9200, Node2: 0.0.0.0:9201, Node3: 0.0.0.0:9202
I use Nest in .NetCore Application. and i connect to cluster with http://:9200/
and this connection works as well.
But when master node fails , connection to :9200 also fails!!!
What is the best approach for this situation?
var uris = Enumerable.Range(9200, 3)
.Select(port => new Uri($"http://0.0.0.0:{port}"));
var pool = new SniffingConnectionPool(uris);
var client = new ElasticClient(new ConnectionSettings(pool));
A sniffing connection pool will periodically sniff the cluster to find the nodes in the cluster. Sniffing uses the publish_address returned for each node, or the first bound_address if there's no publish_address, so ensure that the address returned for each node can be reached by the client. This can be controlled with HTTP or network settings.
As a personal preference I'd generally recommend starting with the StaticConnectionPool and moving to the SniffingConnectionPool later, and then only if you need the sniffing functionality. Many clusters don't need sniffing, or they have alternative mechanisms for finding the client nodes (e.g. DNS or a loadbalancer). Conversely we often see confusion around getting the publish_address right, particularly in today's world of Docker containers and their confusingly inhomogeneous networks. By starting with the StaticConnectionPool you can avoid that confusion until it's absolutely necessary.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.