Always getting following error after couple of SQL statement execution.
I am using
var sql = require("mssql");
(node:12240) [DEP0064] DeprecationWarning: tls.createSecurePair() is deprecated. Please use tls.Socket instead. warning.js:18 (node:12240) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): ConnectionError: Failed to connect to Server-100:undefined in 15000ms warning.js:18 (node:12240) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. warning.js:18 (node:12240) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 4): ConnectionError: Failed to connect to Server-100:undefined in 15000ms warning.js:18
ConnectionError: Failed to connect to server-100:undefined in 15000ms
at Connection.tedious.once.err (d:\API\node_modules\mssql\lib\tedious.js:216:17)
at Object.onceWrapper (events.js:316:30)
at emitOne (events.js:115:13)
at Connection.emit (events.js:210:7)
at Connection.connectTimeout (d:\API\node_modules\tedious\lib\connection.js:634:12)
at ontimeout (timers.js:469:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:264:5)
Following is the code :
module.exports = function (data) {
return new Promise(function (resolve, reject) {
var database = new sql.ConnectionPool({
user: 'sa',
password: 'password',
server: 'Server-100',
database: 'SQLDB',
options: {
encrypt: true,
useUTC: true
},
pool: {
max: 10,
min: 0,
idleTimeoutMillis: 60000
}
});
database.connect().then(function () {
var req = new sql.Request(database);
req.input(data.parameter.Name, data.parameter.DataType, data.parameter.Value);
req.execute(data.procedureName).then(function (result) {
database.close();
return resolve(result);
}).catch(function (err) {
database.close();
return reject(err);
});
}).catch(function (err) {
database.close();
return reject(err);
});
});
}
Exception has occurred: ConnectionError ConnectionError: Failed to connect to 10.0.2.183:undefined in 15000ms at Connection.tedious.once.err (d:\Projects\node_modules\mssql\lib\tedious.js:216:17) at Object.onceWrapper (events.js:316:30) at emitOne (events.js:115:13) at Connection.emit (events.js:210:7) at Connection.connectTimeout (d:\Projects\node_modules\tedious\lib\connection.js:634:12) at ontimeout (timers.js:469:11) at tryOnTimeout (timers.js:304:5) at Timer.listOnTimeout (timers.js:264:5)
Can you suggest what is wrong here?