
[英]Error: read ECONNRESET when connected to a mysql server with Node.js
[英]Node.js + SQL Server error : ConnectionError: Connection lost - read ECONNRESET
我正在使用 node-mssql 链接: https://www.npmjs.com/package/mssql我能够连接到 SQL Server Management Studio。 当我使用节点 js 连接到 SQL 服务器时,我收到了错误消息,并试图寻找解决方案。 但我找不到合适的。
这是我的代码。
const sql = require('mssql')
const config = {
user: 'sx',
password: 'XXXXXX',
server: 'XXX.XXX.XX.XXX',
database: 'XXXX',
options: {
"encrypt": true,
"enableArithAbort": true
},
stream:true,
}
sql.connect(config).then(() => {
return sql.query`select * FROM mydb.Department`
}).then(result => {
console.dir(result)
}).catch(err => {
console.log(err);
// ... error checks
})
sql.on('error', err => {
console.log(1);
// ... error handler
})
$ node index.js // 错误详情 ConnectionError: Connection lost - 在 Connection.socketError (D:\ MakeP\node_modules\mssql\node_modules\tedious\lib\connection.js:1294:54)
在套接字。 (D:\MakeP\node_modules\mssql\node_modules\tedious\lib\connection.js:1125:14)
在 Socket.emit (events.js:326:22) 在emitErrorNT (internal/streams/destroy.js:92:8) 在emitErrorAndCloseNT (internal/streams/destroy.js:60:3) 在 processTicksAndRejections (internal/process/ task_queues.js:84:21) { 代码:'ESOCKET' }
package.json
文件Node js: 12.6.0
{
"name": "makep",
"type": "commonjs",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"async": "^3.2.0",
"express": "^4.17.1",
"mssql": "^6.0.0",
"net": "^1.0.2",
"tedious": "^11.0.4"
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.