I wanted to check if elasticsearch.js was connected to the internet.
So I ran client.ping
in my production environment as follows.
client.ping({
requestTimeout: 30000,
}, function (error) {
if (error) {
console.error('elasticsearch cluster is down!');
} else {
console.log('All is well');
}
});
I received an error log saying "elasticsearch cluster is down!".
On the other hand, when I run client.ping
in my development environment on my own machine, I received a log saying "All is well".
curl
command works on terminal in the production environment.
For example, the following curl
command works.
curl -XPOST 'http://172.31.18.8:9200/users/_search?pretty' -H 'Content-Type: application/json' -d'
{
"suggest" : {
"docsuggest" : {
"text" : "m",
"completion" : {
"field" : "name_suggest",
"fuzzy": true
}
}
}
}'
{
"took" : 10,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : 0.0,
"hits" : [ ]
},
"suggest" : {
"docsuggest" : [
{
"text" : "m",
"offset" : 0,
"length" : 1,
"options" : [
{
"text" : "Mike",
"_index" : "users",
"_type" : "user",
"_id" : "Mike",
"_score" : 1.0,
"_source" : {
"name_suggest" : {
"input" : "Mike"
}
}
}
]
}
]
}
}
I don't know why I'm receiving the "elasticsearch cluster is down!" error in my production environment when using elasticsearch.js.
I can't get data using elasticsearch.js since it's not connected to the internet.
Can anyone tell me what is the likely cause for this error?