elasticsearch python client - work with many nodes - how to work with sniffer -


i have 1 cluster 2 nodes.

i trying understand best practise connect nodes, , check failover when there downtime on 1 node.

from documentation:

es = elasticsearch(     ['esnode1', 'esnode2'],     # sniff before doing     sniff_on_start=true,     # refresh nodes after node fails respond     sniff_on_connection_fail=true,     # , every 60 seconds     sniffer_timeout=60 ) 

so tried connect nodes this:

client = elasticsearch([ip1, ip2],sniff_on_start=true, sniffer_timeout=10,sniff_on_connection_fail=true) 

where ip1/ip2 machine ip's (for example 10.0.0.1, 10.0.0.2)

in order test it, terminated ip2 (or put non existent if) now, when trying connect, get:

transporterror: transporterror(n/a, 'unable sniff hosts - no viable hosts found.')  

even ip1 exist , up.

if trying connect this:

es = elasticsearch([ip1, ip2]) 

then can see in log if client not getting response ip2, move ip1, , return valid response.

so missing here something? thought sniffing, client wont throw exception if 1 of nodes down, , continue working active nodes (until next sniffing)

update: behaviour when ever set sniff 'true':

----> 1 client = elasticsearch([ip1, ip2],sniff_on_start=true)  /usr/local/lib/python2.7/dist-packages/elasticsearch/client/__init__.pyc in __init__(self, hosts, transport_class, **kwargs)     148             :class:`~elasticsearch.connection` instances.     149         """ --> 150         self.transport = transport_class(_normalize_hosts(hosts), **kwargs)     151      152         # namespaced clients compatibility api names  /usr/local/lib/python2.7/dist-packages/elasticsearch/transport.pyc in __init__(self, hosts, connection_class, connection_pool_class, host_info_callback, sniff_on_start, sniffer_timeout, sniff_timeout, sniff_on_connection_fail, serializer, serializers, default_mimetype, max_retries, retry_on_status, retry_on_timeout, send_get_body_as, **kwargs)     128      129         if sniff_on_start: --> 130             self.sniff_hosts(true)     131      132     def add_connection(self, host):  /usr/local/lib/python2.7/dist-packages/elasticsearch/transport.pyc in sniff_hosts(self, initial)     235         # transport_schema or host_info_callback blocked - raise error.     236         if not hosts: --> 237             raise transporterror("n/a", "unable sniff hosts - no viable hosts found.")     238      239         self.set_connections(hosts) 

you need set sniff_timeout higher value default value (which 0.1 if memory serves).

try this

es = elasticsearch(     ['esnode1', 'esnode2'],     # sniff before doing     sniff_on_start=true,     # refresh nodes after node fails respond     sniff_on_connection_fail=true,     # , every 60 seconds     sniffer_timeout=60,     # set sniffing request timeout 10 seconds     sniff_timeout=10 ) 

Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -