Node.js client and ECONNRESET


(Pepa Štefan) #1

Hi, I'm trying to query elasticsearch from node.js and from time to time I get error

[Error: read ECONNRESET] code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read'.

The queries goes one after other, quite quickly, one query takes maybe 30ms to resolve.
Typical query is this one:

POST http://localhost:10200/cloudlog/raw/_search HTTP/1.1
host: localhost:10200
accept: application/json
content-type: application/json
content-length: 109
Connection: close

{"query":{"bool":{"must":[{"match":{"AzId":0}},{"match":{"BatchId":947024}}]}},"sort":["Date"],"size":100000}

What changes is the BatchId.

Response

HTTP/1.1 200 OK
Content-Type: application/json; charset=UTF-8
Content-Length: 16721

{"took":23,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":18,"max_score":null,"hits":[{"_index":"cloudlog","_type":"raw","_id":"AU29j3XLLGqdlAzQW63j","_score":null,"_source":{"AzId":0,"BatchId":947024,"CompanyId":926101,"CompanyName":"ile","Customer":"","Date":"2014-08-25T0...

What's strange is that fiddler shows me no problem with the request and response. What does that error mean?

Node js. source code for calling elasticsearch (using request npm module):

function FindByQuery_promise(query) {
  var deferred = Q.defer();
  var r = request({
      url: this._documentUrl + "/_search",
      method: "POST",
      json: true,
      body: query
  }, function(e, response, body) {
    body = body || { error: null };
    if (e || body.error) {
      console.error("Error", e, body.error);
      deferred.reject(new Error(e || body.error));
    } else {
      deferred.resolve(body);
    }
  });
  return deferred.promise;
}

Any help would be approciated as I don't know when coding whether the response is valid or not. And also sometimes there is no error in dozens of thousands requests and then there are request errors after some hundreds requests...


(Pepa Štefan) #2

Maybe it's really related to Node.js, because it keeps a lot of tcp connections in fin_wait2 state. When I ran Process Monitor and watched node, there were about 40 connections that were disconnected when node exited.

When loooking through Process Explorer, the node is connecting to ES, then the connections are in fin_wait2 for some time and then disconnected.
Maybe lowering limit of connections in fin_wait2 would help..


(system) #3