title: how cluster failover works in ElasticSearch using NEST
body: <p>I am new in Elastic search. I want to know how the cluster failover works in ES using NEST.
  I went through available links <a href="http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html" rel="nofollow">http://nest.azurewebsites.net/elasticsearch-net/cluster-failover.html</a>
  and <a href="http://nest.azurewebsites.net/elasticsearch-net/connecting.html" rel="nofollow">http://nest.azurewebsites.net/elasticsearch-net/connecting.html</a>. But it is not much clear for me. </p>
  
  <p>Suppose i have two nodes. Node1(10.20.2.1:9203) and node2(10.20.2.2:9204). Both nodes are connected to single cluster 'TestCluster'. My requirement is that, if any of the node is down, i want to get the data from live node.</p>
  
  <p>My config file for Node1(10.20.2.1:9203) is as follows</p>
  
  <pre><code>cluster.name: TestCluster
  node.name: "Node1"
  node.master: true
  node.data: true
  network.host: 10.20.2.1
  http.port: 9203
  </code></pre>
  
  <p>My config file for Node2(10.20.2.2:9204) is as follows</p>
  
  <pre><code>cluster.name: TestCluster
  node.name: "Node2"
  node.master: false
  node.data: true
  network.host: 10.20.2.2
  http.port: 9204
  </code></pre>
  
  <p>I am accessing the ES client as follows</p>
  
  <pre><code>private static ElasticClient ElasticClientNew
          {
              get
              {
                  var node = new Uri("http://10.20.2.1:9203");
                  var node1 = new Uri("http://10.20.2.2:9204");
                  var connectionPool = new SniffingConnectionPool(new[] { node, node1 });
                  var setting = new ConnectionSettings(connectionPool)
                                      .SniffOnConnectionFault(false)
                                      .SniffOnStartup(false)
                                      .SniffLifeSpan(TimeSpan.FromMinutes(1));
                  return new ElasticClient(setting);
              }
          }
  </code></pre>
  
  <p>I am using this ES client for searching as follows</p>
  
  <pre><code>var result = ElasticClientNew.Search&lt;Attendance&gt;(s =&gt; s
                              .From(0)
                              .Size(5000)
                              .Index("attendance").Type("Worker"));
  </code></pre>
  
  <p>I am running the MVS application from node1, and elasticsearch service is stopped in this machine. But the ES service is running in node2. When i try to search, am getting error as follows</p>
  
  <pre><code>Failed after retrying 1 times: 'POST attendance/Worker/_search'. 
  InnerException: PingException, InnerMessage: Pinging http://10.20.2.1:9203 caused an exception, InnerStackTrace:    at Elasticsearch.Net.Connection.Transport.Ping(ITransportRequestState requestState) in c:\Users\gmarz\code\elasticsearch-net\src\Elasticsearch.Net\Connection\Transport.cs:line 96
     at Elasticsearch.Net.Connection.Transport.DoRequest[T](TransportRequestState`1 requestState) in c:\Users\gmarz\code\elasticsearch-net\src\Elasticsearch.Net\Connection\Transport.cs:line 334
  </code></pre>
  
  <p>Please suggest how the cluster failover can be achieved in my application.</p>