Tedious.js 不受支持的协议

时间:2021-04-28 15:44:41

标签: node.js express tedious

尝试使用繁琐的方法连接到本地 sql server 数据库时,我看到以下错误。我已经尝试使用 IP 地址和本地主机,但它无法连接。在 sql server 配置管理器中为 MSSQLSERVER 启用 TCP/IP。我还验证了 sql server 浏览器也在运行。

错误:

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

代码:

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

编辑 - 现在更改服务器后出现不同的错误

我在代码中更改了服务器,现在我看到用户“已编辑”的登录失败。知道如何解决这个问题吗?

错误:

 E:\ExpressServer\kagetruckroutingappServer\app.js:36
            throw err;
            ^
    ConnectionError: Login failed for user 'sa'.
        at ConnectionError (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\errors.js:13:12)
        at Parser.<anonymous> (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\connection.js:1171:51)
        at Parser.emit (events.js:314:20)
        at Readable.<anonymous> (E:\ExpressServer\kagetruckroutingappServer\node_modules\tedious\lib\token\token-stream-parser.js:27:14)
        at Readable.emit (events.js:314:20)
        at addChunk (E:\ExpressServer\kagetruckroutingappServer\node_modules\readable-stream\lib\_stream_readable.js:298:12)
        at readableAddChunk (E:\ExpressServer\kagetruckroutingappServer\node_modules\readable-stream\lib\_stream_readable.js:280:11)
        at Readable.push (E:\ExpressServer\kagetruckroutingappServer\node_modules\readable-stream\lib\_stream_readable.js:241:10)
        at E:\ExpressServer\kagetruckroutingappServer\node_modules\readable-stream\lib\internal\streams\from.js:49:29
        at Generator.next (<anonymous>) {
      code: 'ELOGIN'
    }
    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!     C:\Users\chris.kretman\AppData\Roaming\npm-cache\_logs\2021-04-29T12_50_43_835Z-debug.log

代码:

 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
                }
            },
            options: {
                // If you are on Microsoft Azure, you need encryption:
                encrypt: true,
                database: 'master'  //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");  
            
        });

0 个答案:

没有答案