Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unsupported Protocol Error #1251

Closed
kagedevelopment opened this issue Apr 28, 2021 · 25 comments
Closed

Unsupported Protocol Error #1251

kagedevelopment opened this issue Apr 28, 2021 · 25 comments

Comments

@kagedevelopment
Copy link

kagedevelopment commented Apr 28, 2021

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");  
        
    });
@IanChokS
Copy link
Member

IanChokS commented Apr 29, 2021

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

@kagedevelopment
Copy link
Author

$ npm tedious -v
6.14.8

@kagedevelopment
Copy link
Author

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");  
        
    });

@IanChokS
Copy link
Member

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

@kagedevelopment
Copy link
Author

I tried the commands npm install tedious@11.0.8 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

@IanChokS
Copy link
Member

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

@kagedevelopment
Copy link
Author

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.

@IanChokS
Copy link
Member

What sql server version are you using?

@kagedevelopment
Copy link
Author

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

@IanChokS
Copy link
Member

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

@kagedevelopment
Copy link
Author

12.0.2269.0

@IanChokS
Copy link
Member

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)

@kagedevelopment
Copy link
Author

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

@kagedevelopment
Copy link
Author

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.

@kagedevelopment
Copy link
Author

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

@kagedevelopment
Copy link
Author

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

@Estefania-Pichardo-Montes

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_modules\tedious\lib\errors.js:13:12)
at Connection.socketError (C:\Users\Lauro\Documents\PruebaConexionSql\node_modules\tedious\lib\connection.js:1641:56)
at Socket. (C:\Users\Lauro\Documents\PruebaConexionSql\node_modules\tedious\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

@kagedevelopment
Copy link
Author

kagedevelopment commented May 13, 2021

Try adding this options:

options: {
trustServerCertificate: true

}

@IanChokS
Copy link
Member

IanChokS commented May 13, 2021

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

@kagedevelopment
Copy link
Author

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

@Estefania-Pichardo-Montes

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

@irzelindo
Copy link

irzelindo commented Jan 4, 2022

Try adding this options:

options: { trustServerCertificate: true

}

I had the same issue and this solution worked for me. Tks

@kazzi58
Copy link

kazzi58 commented Mar 1, 2022

Try adding this options:

options: { trustServerCertificate: true

}

Where exactly do I have to add this?

@mShan0
Copy link
Contributor

mShan0 commented Mar 1, 2022

Hi @kazzi58, this goes in your config object.

const config = {
  ...,
  options: {
      trustServerCertificate: true
  }
}

You can find more information here: http://tediousjs.github.io/tedious/api-connection.html

@ubilrodriguez
Copy link

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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants