Passing a list of Connections


(Garrett Johnson) #1

I'm using ElasticSearch.net and playing around with Connection Pooling Sniffing etc.

Looking at the docs I don't know how to tell it a list of URi's ...

If I choose just one URI and it is dead how would it figure out the rest?


(Imran Siddique) #2

Example: http://nest.azurewebsites.net/elasticsearch-net/connecting.html


(Garrett Johnson) #3

That example does not show a list of IP's

What happens if:

Uri("http://mynode.example.com:8082/apiKey"); Is down?


(Imran Siddique) #4

it talks about connection pool which takes list of Uris :

var node = new Uri("http://mynode.example.com:8082/apiKey");
var connectionPool = new SniffingConnectionPool(new[] { node });
var config = new ConnectionConfiguration(connectionPool);
var client = new ElasticsearchClient(config);

basically you provide multiple URIs each reflecting ur client node and do the right setting so NEST takes care of load balance and fault tolerance.


(Garrett Johnson) #5

My question is exactly how to do that?

Providing an example that Shows 1 Uri for a setup specifically used for multiple Uri's seems counter intuitive.

Is it a comma separated list, semicolon separated. Since it is a var who knows what node is?

The example isn't clear to me anyway on how to add multiples.


(Imran Siddique) #6

Uri node1 = new Uri("http://10.0.0.1:9200/");
Uri node2 = new Uri("http://10.0.0.2:9200/");
var connectionPool = new SniffingConnectionPool(new[] { node1, node2 });
var config = new ConnectionConfiguration(connectionPool);
var client = new ElasticsearchClient(config);


(Garrett Johnson) #7

Thanks :smile:


(system) #8