From a1ca4e20de5e7b77bbf16ee81258ab27f747608b Mon Sep 17 00:00:00 2001 From: GREsau Date: Thu, 8 Oct 2015 16:27:18 +0100 Subject: [PATCH] Allow connection pooling Allow connection pooling so that requests do not back up when the response time is slower than the flush interval. Handle response data events so that Node is aware we have consumed the response instead of waiting for a remote timeout (see http://stackoverflow.com/questions/15533448/node-js-http-request-problems-with-connection-pooling). --- lib/influxdb.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/influxdb.js b/lib/influxdb.js index f7a8913..e14deb2 100644 --- a/lib/influxdb.js +++ b/lib/influxdb.js @@ -421,8 +421,7 @@ InfluxdbBackend.prototype.httpPOST_v08 = function (points) { hostname: self.host, port: self.port, path: '/db/' + self.database + '/series?' + querystring.stringify(query), - method: 'POST', - agent: false // Is it okay to use "undefined" here? (keep-alive) + method: 'POST' }; var req = self.protocol.request(options); @@ -439,6 +438,8 @@ InfluxdbBackend.prototype.httpPOST_v08 = function (points) { if (status !== 200) { self.log(protocolName + ' Error: ' + status); } + + res.on('data', function(){}); }); req.on('error', function (e, i) { @@ -476,8 +477,7 @@ InfluxdbBackend.prototype.httpPOST_v09 = function (points) { hostname: self.host, port: self.port, path: '/write?' + querystring.stringify(query), - method: 'POST', - agent: false // Is it okay to use "undefined" here? (keep-alive) + method: 'POST' }; var req = self.protocol.request(options); @@ -494,6 +494,8 @@ InfluxdbBackend.prototype.httpPOST_v09 = function (points) { if (status >= 400) { self.log(protocolName + ' Error: ' + status); } + + res.on('data', function(){}); }); req.on('error', function (e, i) {