Hi,
I am trying to connect to my Elasticsearch 8.0 cluster through a Javascript client 8.0 and I am having this error
ConnectionError: other side closed - Local: 172.31.0.1:60684, Remote: 172.31.0.4:9200
at SniffingTransport.request (/home/ilsa/work/fayvo/nodeexpress/node_modules/@elastic/transport/lib/Transport.js:525:31)
at async Client.SearchApi [as search] (/home/ilsa/work/fayvo/nodeexpress/node_modules/@elastic/elasticsearch/lib/api/api/search.js:65:12)
at async data_aggregation (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:340:22)
at async getAggregatedData (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:233:19)
at async responseMapper (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:173:19)
at async isFayvedMapper (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:159:24)
at async get_results (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:95:27)
at async exports.get_web (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/web_trend.js:79:23)
at async Object.exports.get_trends (/home/ilsa/work/fayvo/nodeexpress/suggestion_list/api_caller.js:46:40)
at async exports.get_trend (/home/ilsa/work/fayvo/nodeexpress/controllers/suggestionController.js:5:16) {
meta: {
body: undefined,
statusCode: 0,
headers: {},
meta: {
context: null,
request: [Object],
name: 'elasticsearch-js',
connection: [Object],
attempts: 3,
aborted: false
},
warnings: [Getter]
}
}
{
"data": {
"name": "ConnectionError",
"meta": {
"statusCode": 0,
"headers": {},
"meta": {
"context": null,
"request": {
"params": {
"method": "POST",
"path": "/_search",
"body": "{\"query\":{\"bool\":{\"must\":[{\"match_all\":{}}]}}}",,
"querystring": "",
"headers": {
"user-agent": "elastic-transport-js/8.0.2 (linux 5.13.0-30-generic-x64; Node.js v14.18.3)",
"x-elastic-client-meta": "es=8.0.0,js=14.18.3,t=8.0.2,hc=14.18.3",
"content-type": "application/vnd.elasticsearch+json; compatible-with=8",
"accept": "application/vnd.elasticsearch+json; compatible-with=8",
"content-length": "4485"
}
},
"options": {},
"id": 1
},
"name": "elasticsearch-js",
"connection": {
"url": "http://172.31.0.4:9200/",
"id": "http://172.31.0.4:9200/",
"headers": {},
"status": "alive"
},
"attempts": 3,
"aborted": false
},
"warnings": null
}
}
}
The client that i'm preparing to connect looks something like this
let url = new URL(ELASICSEARCH_HOST)
url['username'] = ELASICSEARCH_USER
url['password'] = ELASICSEARCH_PASS
const client = new Client({
node: {
url: url
}
});
const client = new Client({
node: {
url: new URL(ELASICSEARCH_HOST),
auth: {
username: ELASICSEARCH_USER,
password: ELASICSEARCH_PASS
}
}
});
I have mentioned two client definitions above (i have tried to make connection using both but no success)
can anyone please help me in making a connection to Elasticsearch 8.0 cluster