0

我已经在stackoverflow中搜索了很多关于这个问题的问题,但没有找到解决方案。

我有 2 台服务器。测试 A:Linux ubuntu 14.04 运行和测试 B:Windows 服务器 2008。两台服务器都在同一个网络中。

测试 B:运行 MSSQL 服务器的 windows 服务器。我检查了TCP/IP enabled 它正在运行并且端口是1433(IPALL)。我确认SQL server browser正在服务器中运行。PORT也在网络内部打开。

现在来自测试 A:我正在尝试使用 PORT 1433 和网络中机器的私有 IP 连接测试 B 的 MSSQL。但我明白了Error creating connection pool { Error: Failed to connect to PRIVATEIP:1433 in 1500ms

我在同一个网络测试 C 中还有一台机器,它是一台 Windows 7 机器。我使用了 SQL Server Management Studio 和相同的节点脚本,在这种情况下,从 Windows 7 开始它工作正常。我可以使用相同的代码和配置连接到 SQL 服务器。

我正在使用Express, MSSQL包连接到 MSSQL 服务器。我也用过tedious但同样的问题。

var express = require("express");
var sql = require("mssql");
var config = require("./config.json");

console.log(config.mssql); // i can see the mssql configs here

var conPool = new sql.ConnectionPool(config.mssql);

var app = express();
var PORT = 8080;

conPool.connect(function(err){
        if(err){
            console.error('Error creating connection pool', err);          
        } else {
            console.log('Connection pool is opened');
            app.use(function (req, res, next) {
            req.cp = conPool;
            next();
        })
        require('./routes')(app);
        app.listen(PORT, function () {
            console.log("Server started in port", PORT);
        })

    }
});

连接字符串如下。

{
    "mssql": {
        "user": "username",
        "password": "password",
        "server": "10.789.456.123",
        "database": "Database",
        "port": 1433,
        "dialect": "mssql",
        "dialectOptions": {
            "instanceName": "MSSQLEXPRESS"
        },
        "pool": {
            "min": 2,
            "max": 10
        }                             
    }   
}

我不知道我是否想在 linux 中安装一些 mssql 驱动程序或其他问题。但只有从 linux 我无法访问。

4

0 回答 0