На моем удаленном компьютере установлен статический IP-адрес.Я хочу получить доступ к этому серверу MySQL в другой системе.Я создал соединение на другом компьютере с помощью MySQL Workbench.В Workbench он работает нормально, но когда я пытаюсь подключиться с помощью nodejs, он выдает ошибку.
Код в nodejs:
var sql = require('mysql')
var connection = sql.createConnection({
//properties
host: 'static Ip of my remote Pc',
user: 'username',
password: 'password',
database: 'myDB',
connectionLimit : 100,
waitForConnections : true,
queueLimit :0,
debug : true,
wait_timeout : 28800,
connect_timeout :10,
});
function handleDisconnect() {
connection = sql.createConnection(connection)};
connection.connect(function (error) {
//callback function
if (error) {
if(error.code === 'PROTOCOL_CONNECTION_LOST') {
handleDisconnect();}
else
console.log('error', error);
setTimeout(handleDisconnect, 2000);
} else {
console.log('connected');
}
});
Ошибка:
ошибка:true, сообщение: 'Ошибка iadan Query: 2', статус: 403, данные: {Ошибка: невозможно поставить запрос в очередь после фатальной ошибки.в Protocol._validateEnqueue (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/mysql/lib/protocol/Protoco l.js: 212: 16) в Protocol._enqueue (/Users/harshitkyaltopmail.f/gfl_backend/node_modules/mysql/lib/protocol/Protocol.js:138:13) в Connection.query (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/mysql/lib/Connection.js201:) в userController.list (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/controller/userController.js:9:13) в Layer.handle [как handle_request] (/Users/harshitkyalgmail.com/Desktopggl/node_modules/express/lib/router/layer.js:95:5) на следующем (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/route.js:137:13) местеRoute.dispatch (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/route.js:112:3) в Layer.handle [как handle_request] (/Users/harshitkyalgtop.com/esk/gfl/gfl_backend/node_modules/express/lib/router/layer.js:95:5) в / Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_modules/express/lib/router/index.js:281:22 в параметре (/Users/harshitkyalgmail.com/Desktop/gfl/gfl_backend/node_librou/index.js: 354: 14) код: 'PROTOCOL_ENQUEUE_AFTER_FATAL_ERROR', фатально: false}}]