Requesting Elasticsearch from Node times out
Try extending the requestTimeout parameter when instantiating the ES Client.
client = new elasticsearch.Client({ host : 'http://localhost:9200', requestTimeout: 60000 });
I had a long-running process which took just under 10 minutes. By making the requestTimeout value 60000 (10 mins) the process could complete without timing out.
We also had this issue on QBox because of sniffOnStart.Try with this config:
var es = new elasticsearch.Client({ host: "my-address:9200", log: "trace", sniffOnStart: true});
You'll see that the added nodes ip are the private ip.On our side, we decided to disable the sniffing and add manually the array of public node host addresses like this:
var es = new elasticsearch.Client({ hosts: ["my-address1:9200", "my-address2:9200", "my-address3:9200"], log: "error"});
Regarding timeouts in elastic search, you need to differentiate between two types of timeouts:
Initialization timeout: When you initialize ES:
requestTimeout
,pingTimeout
both of which defaults to 30000ms. Read more: Configuration documentation in elastic search documentationOperation-based timeouts: Many operations such as
bulk
,create
,delete
,index
can settimeout
too. Say if you have a huge bulk object to insert, you can just set operation-based timeouts: Elastic Search documentations
You should know that operation-based timeouts overwrite the initializationRequestTimeout
.