StatusCodeError: Request Timeout after 30000ms in Node JS

I am using elasticSearch 16.7.1

I am doing a multisearch query from node js.
In my local environment, I am able to get the results from the elastic server which is running on http://elasticsearch.tpconnects.com:9200. But when from the aws server i cant get results because of the below error.

StatusCodeError: Request Timeout after 30000ms
0|app | at /home/aggregator-backend/node_modules/elasticsearch/src/lib/transport.js:397:9
0|app | at Timeout. (/home/aggregator-backend/node_modules/elasticsearch/src/lib/transport.js:429:7)
0|app | at Timeout. (/home/aggregator-backend/node_modules/async-listener/glue.js:188:31)
0|app | at listOnTimeout (internal/timers.js:554:17)
0|app | at processTimers (internal/timers.js:497:7) {
0|app | status: undefined,
0|app | displayName: 'RequestTimeout',
0|app | body: undefined
0|app | }
0|app | constituencies undefined

the code I am using is :

const elastiClient = new elasticsearch.Client({

hosts: [ 'http://elasticsearch.tpconnects.com:9200', 'http://elasticsearch.tpconnects.in:9200'],

requestTimeout: 60000

});

const query = req.params.id

let body = {

size: 15,

from: 0,

query: {

  "multi_match" : {

    "query": query,

     "type": "phrase_prefix",

    "fields": [ "iata_code", "country","city","name" ]

    //"operator": "OR"

 }

}

}

elastiClient.search({index:'airports_new', body:body, type:'cities_list'})

.then(results => {

console.log(typeof(results.hits.hits));
res.send(results.hits.hits);

})

.catch(err=>{

console.log(err)

res.send([]);

});

elastiClient.count({index: 'airports_new',type: 'cities_list'},function(err,resp,status) {

console.log("constituencies",resp);

});

In kibana also, I can access the data using search query. But only from production i cant access the data.
Note: elastiClient instance is getting created properly. I consoled the instance in server. Details displayed properly. But after that using that instance, search is not running and giving request timeout error.

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