question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

client.ping returns error, but can access es in browser.

See original GitHub issue

client.ping() returns error ResponseError: parsing_exception.

To Reproduce

'use strict'

const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })

client.ping({
    requestTimeout: 20000,
}, function (error) {
    if (error) {
        console.error('Elasticsearch cluster is down!, ' + error);
    } else {
        console.log('Everything is ok');
    }
});

Expected behavior

A successful connection. 😃

Notes

I can access the server by going to the url in the browser. Also, I’ve indexed a couple documents from node as well -code which ran after I get the error being discussed.

When running ./bin/elasticsearch, I get

OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release. Version: 7.0.0, Build: default/tar/b7e28a7/2019-04-05T22:55:32.697037Z, JVM: 12

I’ve been trying various things, to no avail- adjusting timeout, ‘use strict’, ‘:9200/’, etc. At least I can still use REST. ^_^

Environment

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

18reactions
delvedorcommented, Apr 12, 2019

Hello! In the new JavaScript client every option that is not intended for Elasticsearch lives in a second object, your code should be updated as follows:

'use strict'

const { Client } = require('@elastic/elasticsearch')
const client = new Client({ node: 'http://localhost:9200' })

client.ping({}, { requestTimeout: 20000 }, (err, response) => {
 ...
})

In the response object other than body, statusCode, and headers, you will also find a warnings array and a meta object, which should help you debug issues. In this case, warnings contained the following message: 'Client - Unknown parameter: "requestTimeout", sending it as query parameter'.

1reaction
oscar6echocommented, Jul 1, 2020

@delvedor Just checked and on my Elastic the exact name is monitoring_user.
It worked !

Thx a lot for you quick and precise answer.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Elastic search gives Bad request for ping - node.js
If I try adding new index, delete index, check the health or search, it works fine and gives the appropriate result. Can anyone...
Read more >
How to Troubleshoot a Failed Ping Request | CBT Nuggets
If the nslookup utility fails to find the IP address(es) connected with a domain name, you know there's a problem with the DNS....
Read more >
Can Ping Public IP But Can't Access Internet | USAT FAQs
If pinging IP addresses and domain names is successful while browsing the internet is not, try the following troubleshooting steps: Check the ...
Read more >
elasticsearch.Client.ping JavaScript and Node.js code examples
client.ping({ // ping usually has a 3000ms timeout requestTimeout: Infinity, // undocumented params are appended to the query string hello: "elasticsearch!
Read more >
Elasticsearch is running but it does not connect when the ...
Try again using https both in curl and in the browser to see if the error persists. spo ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found