diff --git a/lib/connection-pool.js b/lib/connection-pool.js index cb217ee..94455d3 100644 --- a/lib/connection-pool.js +++ b/lib/connection-pool.js @@ -19,7 +19,7 @@ var httpOptionsBlob = [] var lastUsed = 0 // limit number of sockets -//http.globalAgent.maxSockets = 3 +http.globalAgent.maxSockets = 10; http.globalAgent.keepAlive = true; function getNextNodeOptions (type) { @@ -55,7 +55,7 @@ module.exports = { connect: function connect (optionString) { var options = parseStringOptions(optionString) options.forEach(function (e) { - httpOptions.push({ + var option = { httpOpt: { host: e.hostname, port: e.port || 4200, @@ -67,7 +67,9 @@ module.exports = { } }, protocol: e.protocol - }) + }; + console.log("Crate Option: ", option); + httpOptions.push(option) httpOptionsBlob.push(e.protocol + '://' + e.hostname + ':' + e.port + '/_blobs/') }) }, diff --git a/lib/index.js b/lib/index.js index 586ff12..0c19922 100644 --- a/lib/index.js +++ b/lib/index.js @@ -96,6 +96,12 @@ function executeSql (sql, args, cb, bulk) { response.on('data', function (chunk) { data.push(chunk) }) + response.on('uncaughtException', function (err) { + cb(err, null) + }) + response.on('error', function (err) { + cb(err, null) + }) response.on('end', function () { var result = {} var json @@ -135,6 +141,11 @@ function executeSql (sql, args, cb, bulk) { }) } var req = connectionPool.getSqlRequest(callback) + + req.on('error', function(err) { + cb(err, null) + }); + var command = { stmt: sql }