ConnectionError: Failed to connect to xxxxx.database.windows.net:1433 - Could not connect (sequence)
We are recently getting a lot of intermittent MSSQL connection error.
We are using SQL Azure with MSSQL for a year without problems. What could happen?
Current error:
ConnectionError: Failed to connect to xxx.database.windows.net:1433 - Could not connect (sequence)
at Connection.tedious.once.err (C:\node\webadmin\node_modules\mssql\lib\tedious.js:237:17)
at Object.onceWrapper (events.js:315:30)
at emitOne (events.js:116:13)
at Connection.emit (events.js:211:7)
at Connection.socketError (C:\node\webadmin\node_modules\mssql\node_modules\tedious\lib\connection.js:1024:14)
at C:\node\webadmin\node_modules\mssql\node_modules\tedious\lib\connection.js:868:25
at SequentialConnectionStrategy.connect (C:\node\webadmin\node_modules\mssql\node_modules\tedious\lib\connector.js:154:9)
at Socket.onError (C:\node\webadmin\node_modules\mssql\node_modules\tedious\lib\connector.js:170:16)
at emitOne (events.js:116:13)
at Socket.emit (events.js:211:7)
Configuration:
var connection = new mssql.ConnectionPool({
user: xxx,
password: xxxx,
server: xxxx,
database: xxx,
port : 1433,
pool: {
idleTimeoutMillis: 60000
},
requestTimeout : 60000,
options: {
encrypt: true
}
});
Software versions
- NodeJS: 8.11.3
- node-mssql: 4.2.1
- SQL Server: SQL Azure
@infoTrainingym
- Firewall your DB server, please
- What debugging have you done? Have you been able to rule anything out?
-
Firewall is open to the ip server. We have another .NET cliente in that machine. Also we try to "allow azure services" on
-
We reuse the connetion to request sql. We used this code.
var connection = new mssql.ConnectionPool({
user: xxx,
password: xxxx,
server: xxxx,
database: xxx,
port : 1433,
pool: {
idleTimeoutMillis: 60000
},
requestTimeout : 60000,
options: {
encrypt: true
}
});
connection .on('error', err => {
closedConnection();
insertLogError("Error bbdd", err, null);
});
connection .connect(function(err1){
if(err1) {
sqlServer = undefined;
insertLogError("Error bbdd", err1, null);
} else {
callback(sqlServer);
}
});
We changed to the promise version, and the problem went away. But we don't really understand why.
var connection = new mssql.ConnectionPool(config)
.connect()
.then(pool => {
connection = pool;
callback(connection);
})
.catch(err => {
closedConexion();
insertLogError("Error bbdd", err1, null);
});
We follow the stacktrace and we find out that in some point, dns lookup failed. The exception was throw at connector.js SequentialConnectionStrategy method.
We follow the stacktrace and we find out that in some point, dns lookup failed.
We've seen this once or twice; you just need to be a bit more resilient with your error handling, I suppose.
Welcome to the joys of Azure ;)
We changed to the promise version, and the problem went away.
I doubt moving to the promise pattern made any real difference and that it's just coincidence, Azure's networking seems to suffer from intermittent problems
Firewall is open to the ip server.
I was able to connect from my local machine...
@dhensby Did you could connect to our server db?
Did you could connect to our server db?
Your server responded on port 1433