I need t o provide the SQL connection (using the library called mssql) for modules, so I provide the code like this:
var config = {
server: "149.xxx.xx.x",
database: "Database",
user: "User",
password: "Password",
connectionTimeout: 300000,
requestTimeout: 300000,
pool: {
idleTimeoutMillis: 300000,
max: 100
}
};
function getEmp() {
var connection = new sql.Connection(config);
var req = new sql.Request(connection);
connection.connect(function (error) {
if(error) {
console.log(error);
return;
}
req.query('Procedure', function(err, data) {
if (err) {
console.log(err);
} else {
console.log(data);
}
connection.close();
});
});
}
getEmp();`
and I receive the error:
{ ConnectionError: Failed to connect to 149.xxx.xx.x:1433 - connect
ETIMEDOUT 149.xxx.xx.x:1433 at Connection.<anonymous>
(/Users/xx/Learning/NodeJS/srv-express/node_modules/mssql/lib/tedious.js:353:25)
at Connection.g (events.js:292:16) at emitOne (events.js:96:13) at
Connection.emit (events.js:188:7) at Connection.socketError
(/Users/xx/Learning/NodeJS/srv-express/node_modules/tedious/lib/connection.js:791:12)
at Socket.<anonymous>
(/Users/xx/Learning/NodeJS/srv-express/node_modules/tedious/lib/connection.js:33:15)
at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at
emitErrorNT (net.js:1277:8) at _combinedTickCallback
(internal/process/next_tick.js:80:11)
name: 'ConnectionError', message: 'Failed to connect to
49.xxx.xx.x:1433 - connect ETIMEDOUT 149.xxx.xx.x:1433', code: 'ESOCKET' }
For sure the data are correct- DataGrip is connecting fine here.
I found at google the similar problem, the problem was Disabled TCP/IP. I checked this one and it's Enabled with this port 1443.
The TCP/IP, Named Pipes and Shared Memory is Enabled.
TCP Dynamic Ports: 1443 TCP Port: empty
{ ConnectionError: Login failed for user 'User'.name: 'ConnectionError', message: 'Login failed for user \'User\'.', code: 'ELOGIN' }Error: 18456, Severity: 14, State: 38.Login failed for user 'User'. Reason: Failed to open the explicitly specified database 'Database Name'. [CLIENT: MYIP]