# How to tell if connection good from JavaScript?

**URL:** <https://discuss.elastic.co/t/how-to-tell-if-connection-good-from-javascript/21802>\
**Category:** Elasticsearch\
**Created:** [January 23, 2015, 5:17pm UTC](https://discuss.elastic.co/t/how-to-tell-if-connection-good-from-javascript/21802 "2015-01-23T17:17:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Blake\_McBride](https://avatars.discourse-cdn.com/v4/letter/b/c67d28/32.png) [@Blake\_McBride](https://discuss.elastic.co/u/Blake_McBride)\
**Post date:** [January 23, 2015, 5:17pm UTC](https://discuss.elastic.co/t/how-to-tell-if-connection-good-from-javascript/21802/1 "2015-01-23T17:17:06Z")

</div>

Greetings,

I am using Node/JavaScript to access elasticsearch. I am using the 1.4 API.

If a connection fails (using new elasticsearch.Client(...)), the 'new'  
succeeds. You don't know the connection failed till you try to use it.  
Okay, I can live with that. What I can't live with is the backtrace I get  
when I try to use it rather than just an error return.

I get no error when I connect (to the wrong port). But I get the following  
when I try to use it:

Elasticsearch ERROR: 2015-01-23T17:14:40Z Error: Request error, retrying --  
connect ECONNREFUSED at Log.error  
(/home/blake/ComponentServer/node\_modules/elasticsearch/src/lib/log.js:213:60)  
at checkRespForFailure  
(/home/blake/ComponentServer/node\_modules/elasticsearch/src/lib/transport.js:195:18)  
at HttpConnector.  
(/home/blake/ComponentServer/node\_modules/elasticsearch/src/lib/connectors/http.js:154:7)  
at ClientRequest.bound  
(/home/blake/ComponentServer/node\_modules/elasticsearch/node\_modules/lodash-node/modern/internals/baseBind.js:56:17)  
at ClientRequest.emit (events.js:95:17) at Socket.socketErrorListener  
(http.js:1552:9) at Socket.emit (events.js:95:17) at net.js:441:14 at  
process.\_tickCallback (node.js:442:13) Elasticsearch WARNING:  
2015-01-23T17:14:40Z Unable to revive connection: [http://localhost:920/](http://localhost:920/)  
Elasticsearch WARNING: 2015-01-23T17:14:40Z No living connections error: No  
Living connections

I tried using client.cluster.health and client.ping with the same results.

Thanks for the help!

Blake McBride

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/305807ef-2952-4ee9-88e9-653122269b3e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/305807ef-2952-4ee9-88e9-653122269b3e%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 12:37am UTC](https://discuss.elastic.co/t/how-to-tell-if-connection-good-from-javascript/21802/2 "2017-07-06T00:37:00Z")

</div>

Closed on July 6, 2017, 12:37am UTC


