
[英]Node.js MSSQL tedius ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED
[英]failed to connect to xxxxx:xxxx in 150000ms node mssql
我有一个节点 js 工作。 该作业每小时使用 node-cron 运行一些逻辑。 它使用节点 mssql package 连接到 sql 服务器数据库。
连接文件代码:
const sql = require('mssql'); const conn = (function () { try { return new sql.ConnectionPool(obj); } catch (err) { throw err; } }()) const pool = (function () { try { return conn.connect(); } catch (err) { throw err; } }()); const myConn = async function getConn() { try { return await pool; } catch (err) { throw err; } }; module.exports = { myConn }
调用存储过程的代码:
async function callProc(procedureName, inputList, callback) { try { const pool = await connectionFile.myConn(); const request = new sql.Request(pool); if (inputList) { for (const param of inputList) { request.input(param.name, param.type, param.value); } } const result = await request.execute(procedureName); callback(null, result); } catch (err) { callback(err, null); } }
我的工作间歇性地因错误“未能在 15000 毫秒内连接”而失败
有什么建议吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.