tedious: Unsupported Protocol Error

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! kagetruckroutingappserver@0.0.0 start: node ./bin/www npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the kagetruckroutingappserver@0.0.0 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");  
        
    });

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 25 (8 by maintainers)

Most upvoted comments

a mi me sale este error:

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

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

Try adding this options:

options: { trustServerCertificate: true

}

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

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.

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)