请求错误: { message: '只能在 LoggedIn 状态下发出请求,不能在 SentLogin7WithStandardLogin 状态下发出', code: 'EINVALIDSTATE' }

gpa*_*oli 5 sql-server node.js npm tedious

tedious当使用包连接到 MSSQL时,我在请求测试中收到以下错误:

'只能在LoggedIn状态下发出请求,不能在SentLogin7WithStandardLogin状态下发出请求',代码:'EINVALIDSTATE'

我的代码(摘自示例:http ://pekim.github.io/tedious/getting-started.html ):

<!-- testDb.js -->

var Connection = require('tedious').Connection;

var config = {
    userName: 'xpto',
    password: 'pass',
    server: 'myserver',
    options: { encrypt: true, database: 'dbname' }
};

var connection = new Connection(config);

connection.on('connect', function (err) {
    var Request = require('tedious').Request;
    request = new Request("select 42, 'hello world'", function (err, rowCount) {
        if (err) {
            console.log('ERROR');
            console.log(err);
        } else {
            console.log(rowCount + ' rows');
        }
    });

    request.on('row', function (columns) {
        columns.forEach(function (column) {
            console.log(column.value);
        });
    });

    connection.execSql(request);
});
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述 提前致谢。

gpa*_*oli 3

我的问题是连接超时。

err事件参数connect返回以下消息:

{ message: '在 15000 毫秒内无法连接到 ip_my_server:1433', code: 'ETIMEOUT' }

请参阅@arthurschreiber对我在项目 github 中的问题 的评论: https://github.com/pekim/tedious/issues/344#issuecomment-161320176

谢谢@arthurschreiber