Tedious: Unsupported Protocol Error

Created on 28 Apr 2021  路  21Comments  路  Source: tediousjs/tedious

I am seeing the below error when trying to connect to a local sql server database using tedious. I have tried both using the IP address and localhost and it won't connect. TCP/IP is enabled for MSSQLSERVER in sql server configuration manager. I also verified that sql server browser is also running.

Error:

ConnectionError: Failed to connect to 127.0.0.1:1433 - 22996:error:1425F102:SSL routines:ssl_choose_client_version:unsupported protocol:c:\ws\deps\openssl\openssl\ssl\statem\statem_lib.c:1942:

at ConnectionError (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\errors.js:13:12)
at Connection.socketError (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\connection.js:1641:56)
at Socket.<anonymous> (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\connection.js:1405:14)
at Socket.emit (events.js:326:22)
at emitErrorNT (internal/streams/destroy.js:100:8)
at emitErrorCloseNT (internal/streams/destroy.js:68:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21) {

code: 'ESOCKET'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: node ./bin/www
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! Redacted

Code:

var Connection = require('tedious').Connection; 
var Request = require('tedious').Request;  
console.log('start')
var config = {
  server: 'localhost',
  authentication: {
    type: 'default',
    options: {
      userName: 'redacted', // update me
      password: 'redacted' // update me
    },
    options: {
      encrypt: false, 
      cryptoCredentialsDetails: {
        minVersion: 'TLSv1'
    }
    }
  }
}
    var connection = new Connection(config);  
    console.log('after connection variable')
    connection.connect();
    console.log('after connect')
    connection.on('connect', function(err) { 
      if (err) {
        console.log('Connection Failed');
        throw err;
      } 
        // If no error, then good to proceed.
        console.log("Connected");  

    });

All 21 comments

@kagedevelopment what version of tedious and sql server are you using?

$ npm tedious -v
6.14.8

I changed the server based on what I saw on Microsofts website and I'm now getting the error failed to login as user 'redacted'

var Connection = require('tedious').Connection; 
var Request = require('tedious').Request;  
console.log('start')
var config = {
  server: 'localhost.database.windows.net',  //update me
        authentication: {
            type: 'default',
            options: {
                userName: 'redacted', //update me
                password: 'redacted' //update me
            }
        },

}
    var connection = new Connection(config);  
    console.log('after connection variable')
    connection.connect();
    console.log('after connect')
    connection.on('connect', function(err) { 
      if (err) {
        console.log('Connection Failed');
        throw err;
      } 
        // If no error, then good to proceed.
        console.log("Connected");  

    });

Are you able to login using the latest version of tedious?

I tried the commands npm install [email protected] and npm install tedious@latest and neither of them updated the version when i run the command npm tedious -v I still get 6.14.8

the latest version is 11.0.7. Try running the commands: npm uninstall tedious then npm i tedious. That should install the latest one

I am using version 11.0.7 now and I am still seeing the same error. I have verified that TCP/IP is enabled for MSSQLSERVER, SQL Server Browser is running and SQL Server agent is running. I am able to log into SSMS just fine using the credentials I am using in my code. Any idea what the issue is? I have seen people use just localhost or the IP Address for their connection. Why does mine only get to login failed when using localhost.database.windows.net as the server? When I don't use that as the server it throws the original error that I posted.

What sql server version are you using?

SQL Server Management Studio 15.0.18206.0
Microsoft Analysis Services Client Tools 15.0.1567.0
Microsoft Data Access Components (MDAC) 6.3.9600.17415
Microsoft MSXML 3.0 5.0 6.0
Microsoft Internet Explorer 9.11.9600.19963
Microsoft .NET Framework 4.0.30319.42000
Operating System 6.3.9600

I mean what version of the database are you using? You can follow these steps to get the exact version

12.0.2269.0

In regards to your first error and according to Microsoft's docs: TLS Support for SQL 2014 RTM is currently only available by installing 2014 SP2 and 2014 SP3 . which might explain the error message you were receiving: routines:ssl_choose_client_version:unsupported protocol

Try to install 2014 SP2 and see if that helps. (If you scroll down, they also claimed to have Provide a method to find out the TLS/SSL protocol used by the client connection in 2014 SP2, so installing this should help)

I'm not going to be able to dig into this until Monday. I will let you know the results then. Thank you!

I have a ticket open with Internal IT to update this on our server. I will let you know the results once this is updated.

They are set to do the update on Wednesday of this coming week. I will test Thursday and follow-up.

Updating SQL server fixed the issue. Thank you for your assistance!

Hi, i have a similar problem, i can't connect to my database althrought the protocol TCP/IP is enabled in my computer, also make sure all the sql services are running, i got this error

ConnectionError: Failed to connect to localhost:1433 - self signed certificate
at ConnectionError (C:\Users\Lauro\Documents\PruebaConexionSql\node_modulestedious\lib\errors.js:13:12)
at Connection.socketError (C:\Users\Lauro\Documents\PruebaConexionSql\node_modulestedious\lib\connection.js:1641:56)
at Socket. (C:\Users\Lauro\Documents\PruebaConexionSql\node_modulestedious\lib\connection.js:1405:14)
at Socket.emit (events.js:322:22)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
message: 'Failed to connect to localhost:1433 - self signed certificate',
code: 'ESOCKET'
}

my code:

const config = {
server: 'localhost',
authentication: {
type: 'default',
options: {
userName: 'user',
password: ''
}
},
options: {
encrypt: true,
database: 'db'
}
};

const Connection = require('tedious').Connection;
const config = require('./dbconfig');

const connection = new Connection(config);
connection.connect();

connection.on('connect', function(err) {
if (err) {
console.log(err);
} else {
console.log('Connected');
}
});

im using the version of database 15.0.2000.5

SQL Server Management Studio 15.0.18330.0
SQL Server Management Objects (SMO) 16.100.37971.0
Microsoft Analysis Services Client Tools 15.0.19040.0
Microsoft Data Access Components (MDAC) 10.0.19041.1
Microsoft MSXML 3.0 6.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.19042

Try adding this options:

options: {
trustServerCertificate: true

}

@kagedevelopment can you open a new issue for this? (so we can better track it)

@Estefania-Pichardo-Montes If you are still having this issue, can you please create a separate issue for this?

Hey, i already resolve the issue, adding the suggested option i get another error but i realize that the error was that i was using the user of windows authentication instead of an sql server user, thank you

Was this page helpful?
0 / 5 - 0 ratings