nodejs mssql连接ETIMEDOUT

时间:2018-12-16 03:47:51

标签: node.js sql-server connect

  

(节点:6561)UnhandledPromiseRejectionWarning:ConnectionError:Failed   连接到1.1.1.1:1433-连接ETIMEDOUT 1.1.1.1:1433       在Connection.tedious.once.err(/home/api_server/node_modules/mssql/lib/tedious.js:239:17)       在Object.onceWrapper(events.js:315:30)       在emitOne上(events.js:116:13)       在Connection.emit(events.js:211:7)       在Connection.socketError(/home/api_server/node_modules/tedious/lib/connection.js:1024:14)       在/home/api_server/node_modules/tedious/lib/connection.js:868:25       在Socket.onError(/home/api_server/node_modules/tedious/lib/connector.js:49:9)       在emitOne上(events.js:116:13)       在Socket.emit(events.js:211:7)       在emitErrorNT(internal / streams / destroy.js:66:8)(node:6561)处UnhandledPromiseRejectionWarning:未处理的Promise拒绝。这个   由抛出异步函数引起的错误   没有障碍,或者拒绝了没有处理的承诺   使用.catch()。 (拒绝ID:20)

这是来源:

// Database
exports.DEF_DB = {
    server          : '.1.1.1',
    database        : 'CA_SUPER_INFO',
    user                : 'user',
    password    : 'pass',
    port                : 1433,
    pool: {
        acquireTimeoutMillis: 15000
    }
};


exports.checkUserLogin = function ( data , callback ) {


    var conn = new sql.ConnectionPool(CONFIG.DEF_DB);

    conn.connect().then ( function () {

        var req = new sql.Request(conn);

        console.log("[socket] %j" , data);

        req.input ('c_key'      ,sql.VarChar(250)       ,data.com_key);
        req.input ('c_id'           ,sql.VarChar(30)        ,data.user_id);
        req.input ('c_pw'           ,sql.VarChar(30)        ,data.user_pw);
        req.input ('c_os'           ,sql.VarChar(30)        ,data.user_device);
        req.input ('c_ip'           ,sql.VarChar(16)        ,data.user_ip);
        req.input ('c_info'     ,sql.VarChar(250)       ,JSON.stringify(data));

        req.execute ("CA_SUPER_INFO.dbo.proc_api_user_login" , function ( err , recordsets ) {

            if(err){
                insertErr("proc_api_user_login" , err);
                callback(5);
            }else{
                callback(recordsets.recordset[0]);
            }
            conn.close();
        })

    }).catch(err => {
        console.log("proc_api_user_login");
    });
};

我根据these docs进行了修改,但仍然遇到错误

0 个答案:

没有答案