I am using the mssql node.js module to connect with SQL Server 2005.
It used to work fine when I started, with version 1.1.0 however when I upgraded today to the new version (3.3.0) it stopped working and started throwing Connection Timeout errors.
After some trial and error, I found that if I remove the encrypt: true
from the options, it works.
I would still like to have the connection encrypted, so wonder if anyone can explain why this happens, and if there is any way to fix this?
The code which is failing is essentially this:
var sql = require('mssql');
var router = express.Router();
router.use(function(req, res, next){
// Add database connection
var connection = new sql.Connection(sqlConfig: {
user: 'username',
password: 'password',
server: 'IP address',
database: 'database name',
options: {
encrypt: true
}
}, function(err) {
if (err) {
logger.error('Connection error: ' + err.message);
res.sendStatus(400);
}
else {
req.connection = connection;
next();
}
});
});
module.exports = router;
The error I get is:
Connection error: Failed to connect to [server IP]:1433 in 15000ms