admin管理员组文章数量:1425815
I have this issue since I uploaded my code on hosting panel, my Database is different server and API is a different server
The error is code: "PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR", fatal: false}
it is working for some time but after calling another API then an error is occurring. Here is my code
app.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
Here is the controller user.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
})
This is one code snippet of my API.
exports.getLandLord =(req, res, next)=>{
var sql =`SELECT *FROM registrations`;
connection.query(sql, function(error, result, field){
if(error){
return res.status(201).json({message:error, status:402, success:false})
}
else
if(result.length>0){
res.status(200).json({message:"Land Loard List", status:200, success:true,
users:result,})
}
else
res.status(200).json({message:"No Record Found ", status:402, success:false, users:result})
})
}
I tried googling but I was not able to make it fix.
Please can anyone help me with this issue
Your response and help would be highly appreciated
Thanks in advance.
I have this issue since I uploaded my code on hosting panel, my Database is different server and API is a different server
The error is code: "PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR", fatal: false}
it is working for some time but after calling another API then an error is occurring. Here is my code
app.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
});
connection.connect(function(err) {
if (err) {
console.error('error connecting: ' + err.stack);
return;
}
console.log('connected as id ' + connection.threadId);
});
Here is the controller user.js
var mysql = require('mysql');
var connection = mysql.createConnection({
host : 'xx.xx.xx.xx',
user : 'abc',
password : '123',
database : 'XYZ',
})
This is one code snippet of my API.
exports.getLandLord =(req, res, next)=>{
var sql =`SELECT *FROM registrations`;
connection.query(sql, function(error, result, field){
if(error){
return res.status(201).json({message:error, status:402, success:false})
}
else
if(result.length>0){
res.status(200).json({message:"Land Loard List", status:200, success:true,
users:result,})
}
else
res.status(200).json({message:"No Record Found ", status:402, success:false, users:result})
})
}
I tried googling but I was not able to make it fix.
Please can anyone help me with this issue
Your response and help would be highly appreciated
Thanks in advance.
Share Improve this question edited Jan 29, 2020 at 6:31 FanoFN 7,1242 gold badges16 silver badges35 bronze badges asked Jan 29, 2020 at 6:07 K.SK.S 4631 gold badge12 silver badges31 bronze badges 8- Is your server running? (e.g node start app.js) – FanoFN Commented Jan 29, 2020 at 6:26
- Yes it is running in my case it sever.js – K.S Commented Jan 29, 2020 at 6:32
- 1 Even I testing it with using localhost but online database connection same error occurring after some time later – K.S Commented Jan 29, 2020 at 6:33
- Does this answer your question? Node JS Mysql PROTOCOL ENQUEUE AFTER FATAL ERROR – Prakash Karena Commented Jan 29, 2020 at 6:34
- I visited it but unable to implement it – K.S Commented Jan 29, 2020 at 6:35
1 Answer
Reset to default 2After struggling for a long time I work around this and got code to work refer NodeJS MySQL - How to know connection is release or not
本文标签: javascriptcode quotPROTOCOLENQUEUEAFTERFATALERRORquot in nodeJs MySQLStack Overflow
版权声明:本文标题:javascript - code: "PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR" in nodeJs MySQL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745428000a2658201.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论