Will Elasticsearch automatically load balance a two node cluser

I have a two node cluster. I currently connect to the master node using the Python Elasticsearch client.
Will python automatically distibute the query traffice between the two nodes or do I need to take special actions?
I did some research and it was suggested to accompish this as follows:
es = Elasticsearch(["135.109.238.70", "135.109.238.66"],
sniff_on_start=True,
sniff_on_connection_fail=True,
sniffer_timeout=60
)
However, when I add the sniff_on_start=True line, the python script fails with the following message.
Traceback (most recent call last):
File "./ts.py", line 22, in
res = es.search(index="mcdocs", body={"from": 0, "size": 10, "_source": {"excludes": [ "content" ]}, "query": {"match": {"content": "5g planning installation"}}})
File "/usr/local/lib/python3.7/site-packages/elasticsearch/client/utils.py", line 84, in _wrapped
return func(*args, params=params, **kwargs)
File "/usr/local/lib/python3.7/site-packages/elasticsearch/client/init.py", line 819, in search
"GET", _make_path(index, "_search"), params=params, body=body
File "/usr/local/lib/python3.7/site-packages/elasticsearch/transport.py", line 350, in perform_request
timeout=timeout,
File "/usr/local/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 245, in perform_request
raise ConnectionError("N/A", str(e), e)
elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x7f775ea76198>: Failed to establish a new connection: [Errno -2] Name or service not known) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x7f775ea76198>: Failed to establish a new connection: [Errno -2] Name or service not known)

If I remove the sniff_on_start=True or set it to False, the connection and query are successful. Will Elasticsearch load balance without the sniff_on_start or are there any other suggestions?
Also, how can I tell if queries/traffic are actually being balanced between the two nodes. I am not seeing entries for individual queries.
Thank you for any help with this!

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.