elasticsearch-js: Unable to revive connection

Hello,

I keep getting this error, and it never recovers. I’m using Elasticsearch 1.3.2 and elasticsearch-js 2.4.0 (node client)

Elasticsearch WARNING: 2014-09-09T08:09:05Z
  Unable to revive connection: https://elasticsearch.****.net/

Elasticsearch WARNING: 2014-09-09T08:09:05Z
  No living connections

Here is my configuration

{
    apiVersion:'1.3',
    sniffOnConnectionFault:true,
    maxRetries:5,
    keepAlive:true,
    connectionClass:'http'
}

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Reactions: 6
  • Comments: 62 (5 by maintainers)

Most upvoted comments

My problem has been solved.

code

let client = new elasticsearch.Client({
    host: 'hostname.domain:9200',
    maxSockets: 20,
    keepAlive: false,  
    requestTimeout: 300000,
    sniffInterval: false
});
try {
    await client.search({
        index: 'index',
        body: {"query": {"match_all": {}}},
    });
} catch (error) {

} finally {
    client.close();
}

version

node: v8.12.0

elasticsearch.js: 15.1.1

elasticsearch: 6.4.2

I was facing the same problem. For me issue was with setting auth configuration. Following configuration is worked for me.

var client = new elasticsearch.Client( {  
  host: [
    {
      host: '127.0.0.1',
      auth: 'username:password',
      protocol: 'http',
      port: 9200
    }
  ]
});

For dev purposes only, mine was resolved with http.cors.enabled and http.cors.allow-origin

How can i fix it ? . Plz help me 😦

Elasticsearch INFO: 2017-01-11T03:19:19Z Adding connection to http://localhost:9200/

Elasticsearch DEBUG: 2017-01-11T03:19:19Z starting request { “method”: “HEAD”, “requestTimeout”: 5000, “castExists”: true, “path”: “/”, “query”: {} }

Elasticsearch DEBUG: 2017-01-11T03:19:19Z starting request { “method”: “PUT”, “path”: “/chesshub”, “query”: {} }

(node:7088) DeprecationWarning: Mongoose: mpromise (mongoose’s default promise l ibrary) is deprecated, plug in your own promise library instead: http://mongoose js.com/docs/promises.html Elasticsearch TRACE: 2017-01-11T03:19:20Z -> HEAD http://localhost:9200/

<- 0

Elasticsearch ERROR: 2017-01-11T03:19:20Z Error: Request error, retrying HEAD http://localhost:9200/ => connect ECONNREFUSED 127.0.0.1:9200 at Log.error (C:\Users\MyPC\Desktop\gamehub.io-master\node_modules\elastic search\src\lib\log.js:225:56) at checkRespForFailure (C:\Users\MyPC\Desktop\gamehub.io-master\node_modul es\elasticsearch\src\lib\transport.js:240:18) at HttpConnector.<anonymous> (C:\Users\MyPC\Desktop\gamehub.io-master\node _modules\elasticsearch\src\lib\connectors\http.js:162:7) at ClientRequest.wrapper (C:\Users\MyPC\Desktop\gamehub.io-master\node_mod ules\elasticsearch\node_modules\lodash\lodash.js:4968:19) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at Socket.socketErrorListener (_http_client.js:309:9) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1281:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

Elasticsearch TRACE: 2017-01-11T03:19:20Z -> PUT http://localhost:9200/chesshub

<- 0

Elasticsearch ERROR: 2017-01-11T03:19:20Z Error: Request error, retrying PUT http://localhost:9200/chesshub => connect ECONNREFUSED 127.0.0.1:9200 at Log.error (C:\Users\MyPC\Desktop\gamehub.io-master\node_modules\elastic search\src\lib\log.js:225:56) at checkRespForFailure (C:\Users\MyPC\Desktop\gamehub.io-master\node_modul es\elasticsearch\src\lib\transport.js:240:18) at HttpConnector.<anonymous> (C:\Users\MyPC\Desktop\gamehub.io-master\node _modules\elasticsearch\src\lib\connectors\http.js:162:7) at ClientRequest.wrapper (C:\Users\MyPC\Desktop\gamehub.io-master\node_mod ules\elasticsearch\node_modules\lodash\lodash.js:4968:19) at emitOne (events.js:96:13) at ClientRequest.emit (events.js:188:7) at Socket.socketErrorListener (_http_client.js:309:9) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at emitErrorNT (net.js:1281:8) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

Elasticsearch TRACE: 2017-01-11T03:19:21Z -> HEAD http://localhost:9200/

<- 0

Elasticsearch WARNING: 2017-01-11T03:19:21Z Unable to revive connection: http://localhost:9200/

Elasticsearch WARNING: 2017-01-11T03:19:21Z No living connections

elasticsearch is down! Elasticsearch TRACE: 2017-01-11T03:19:21Z -> HEAD http://localhost:9200/

<- 0

Elasticsearch WARNING: 2017-01-11T03:19:21Z Unable to revive connection: http://localhost:9200/

Elasticsearch WARNING: 2017-01-11T03:19:21Z No living connections

Elasticsearch DEBUG: 2017-01-11T03:19:21Z starting request { “method”: “POST”, “path”: “/chesshub/game/1/_create”, “body”: { “white”: “Foo”, “black”: “Anonymous”, “content”: “1. e4 e5 2. Nf3 Nc6 3. Bc4 Nf6 4. O-O Bc5 5. c3 O-O 6. d4 exd4 7. cxd4 Bb4”, “result”: “1-0” }, “query”: {} }

Elasticsearch TRACE: 2017-01-11T03:19:22Z -> HEAD http://localhost:9200/

<- 0

Elasticsearch WARNING: 2017-01-11T03:19:22Z Unable to revive connection: http://localhost:9200/

Elasticsearch WARNING: 2017-01-11T03:19:22Z No living connections

Elasticsearch DEBUG: 2017-01-11T03:19:23Z starting request { “method”: “POST”, “path”: “/chesshub/game/2/_create”, “body”: { “white”: “Anonymous”, “black”: “Bar”, “content”: "1. e4 c6 2. e5 d5 3. exd6 exd6 4. Nf3 Bg4 5. d4 Nf6 6. Bg5 Be7 ", “result”: “1-0” }, “query”: {} }

Elasticsearch TRACE: 2017-01-11T03:19:24Z -> HEAD http://localhost:9200/

<- 0

Elasticsearch WARNING: 2017-01-11T03:19:24Z Unable to revive connection: http://localhost:9200/

Elasticsearch WARNING: 2017-01-11T03:19:24Z No living connections

@breakbild I’m still receiving this error message:

Error: Request complete with error
GET http://...:9200/_nodes/_all/clear => connect EMFILE ...:9200 - Local (undefined:undefined)

Followed by

Elasticsearch WARNING:
 Unable to revive connection: http://...

I’ve also tried to upgrade to v12 rc4, without success.

Is there any other strategy guys?

We solved this problem for good with the custom http agent “workaround”. You need to install the agentkeepalive module, but hey, if it solves the issue… Example code (you don’t need to specify all options; it’s just a snippet of what we use. We’re using Elasticsearch 2.3, node 5.3). See also #196.

var elasticsearch = require('elasticsearch');
var AgentKeepAlive = require('agentkeepalive');
var client = new elasticsearch.Client({
        hosts: ['localhost:9200'],
        maxRetries: 10,
        keepAlive: true,
        maxSockets: 10,
        minSockets: 10,
        createNodeAgent: function (connection, config) {
          return new AgentKeepAlive(connection.makeAgentConfig(config));
        }
      }
);

I am also getting this same error. We have tried setting keepAlive to false and the app actually fails faster. I can’t find anything in the other issues that fixes this problem.

elasticsearch: 1.5.14 forever-agent: 0.5.2 lodash-node: 2.4.1

node: 0.10.26

I have seen this timeout error just before all of the no living connections errors, but not all the time.

Elasticsearch ERROR: 2014-09-10T19:52:11Z
  Error: Request error, retrying -- connect ETIMEDOUT
      at Log.error (/Users/.../node_modules/elasticsearch/src/lib/log.js:213:60)
      at checkRespForFailure (/Users/.../elasticsearch/src/lib/transport.js:185:18)
      at HttpConnector.<anonymous> (/Users/.../node_modules/elasticsearch/src/lib/connectors/http.js:150:7)
      at ClientRequest.bound (/Users/.../node_modules/elasticsearch/node_modules/lodash-node/modern/internals/baseBind.js:56:17)
      at ClientRequest.EventEmitter.emit (events.js:95:17)
      at Socket.socketErrorListener (http.js:1547:9)
      at Socket.EventEmitter.emit (events.js:95:17)
      at net.js:440:14
      at process._tickCallback (node.js:415:13)