I have installed elasticsearch
python package and I have created a elastic clustere. I am using below python code to send data to elastic cloud:
from elasticsearch import Elasticsearch, RequestsHttpConnection
import time
import datetime
es = Elasticsearch(['70.19.172.110:9200'],http_auth=('<username>','<password>'))
for x in range(0,5):
es.index(index='test', doc_type='json', id=x, body={
'data1':"Hello World',
'value':325,
'time': datetime.datetime.now()
})
print("Data sent {} ".format(x))
time.sleep(60)
So as you can see in the code I am sending the data with the interval of 1min time.sleep(60)
. This works fine and all the 5 data's are in the elasticsearch. Then I changed the time.sleep(60)
to time.sleep(300)
and it gave me below error:
elasticsearch.exceptions.ConnectionTimeout: ConnectionTimeout caused by - ReadTimeoutError(HTTPConnectionPool(host='70.19.172.110', port=9200): Read timed out. (read timeout=10))
Is there anything which I am doing wrong. Is there any way I can keep connected to the elasticsearch so that I dont't through these types of errors.
Thanks.