I recently uploaded my node.js app on A2 Hosting and I get this error :
{ Error: Packets out of order. Got: 80 Expected: 0
at Parser.write (/home/westudec/public_html/myapp/node_modules/mysql/lib/protocol/Parser.js:42:19)
at Protocol.write (/home/westudec/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/westudec/public_html/myapp/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
--------------------
at Protocol._enqueue (/home/westudec/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/westudec/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at Connection.connect (/home/westudec/public_html/myapp/node_modules/mysql/lib/Connection.js:130:18)
at Object.<anonymous> (/home/westudec/public_html/myapp/app2.js:22:7)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10) code: 'PROTOCOL_PACKETS_OUT_OF_ORDER', fatal: true }
I get that error from this code :
var connection = mysql.createConnection(connDB);
connection.connect();
connection.query(`SELECT * FROM action`, function(err, data){
if(err) return console.error(err);
else {
console.log("data : ", data);
}
})
On my localhost it works perfectly but on the server I get that error. The documentation about this error is very poor.
Does someone have an idea ?
Thank you
You need to increase mysql max_allowed_packet parameter in mysql configuration file (my.cnf) by the next way:
max_allowed_packet=500M
Related
I am currently working on c9 IDE and when I run the code below, it gives me errors. How do I get around this Issue?
app.js
var mysql = require("mysql");
var connection = mysql.createConnection({
host: 'localhost',
user: 'poream3387',
database: 'join_us'
});
var q = 'SELECT CURTIME() as time, CURDATE as date, NOW() as now';
connection.query(q, function (error, results, fields) {
if (error) throw error;
console.log(results);
});
connection.end();
command:
node app.js
error:
/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: ER_BAD_FIELD_ERROR: Unknown column 'CURDATE' in 'field list'
at Query.Sequence._packetToError (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:278:23)
at Parser.write (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:38:16)
at Socket. (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:91:28)
at Socket. (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:502:10)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
--------------------
at Protocol._enqueue (/home/ubuntu/workspace/node_modules/mysql/lib/protocol/Protocol.js:144:48)
at Connection.query (/home/ubuntu/workspace/node_modules/mysql/lib/Connection.js:200:25)
at Object. (/home/ubuntu/workspace/app.js:12:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
I think, the issue is with not making CURDATE a function call by adding parenthesis, which is the same thing pointed out by #Jamie D
/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:80
throw err; // Rethrow non-MySQL errors
^
Error: ER_ACCESS_DENIED_ERROR: Access denied for user ''#'localhost' (using password: YES)
at Handshake.Sequence._packetToError (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
at Handshake.ErrorPacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/sequences/Handshake.js:130:18)
at Protocol._parsePacket (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:279:23)
at Parser.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Parser.js:76:12)
at Protocol.write (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
--------------------
at Protocol._enqueue (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/gayathri/jsonhbs/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at Connection.connect (/home/gayathri/jsonhbs/node_modules/mysql/lib/Connection.js:130:18)
at Object.<anonymous> (/home/gayathri/jsonhbs/db1.js:8:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
In your error message, you can clearly see that you did not send the correct user field with the mysql connection call.
Ensure that you send the user you would like to connect as.
Which mysql library are you using? In felix-node-mysql, you must pass the following object:
mysql.createConnection({host:"localhost",user:"root",password:"secretpasshere"},function(...){...})
Here is my (very simple) code :
var connection = mysql.createConnection(infosDB);
connection.connect()
connection.query(`SELECT * FROM action`, function(err, data){
console.log(data);
})
The action table is not empty... I think my database is ok.
This code works very well for me on localhost.
However, I bought A2 Hosting to launch node.js (v6.10.3 on localhost and server) project and I get that error when I try to launch this simple code.
{ Error: Packets out of order. Got: 80 Expected: 0
at Parser.write (/home/hello1234/public_html/myapp/node_modules/mysql/lib/protocol/Parser.js:42:19)
at Protocol.write (/home/hello1234/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/hello1234/public_html/myapp/node_modules/mysql/lib/Connection.js:103:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
at TCP.onread (net.js:547:20)
--------------------
at Protocol._enqueue (/home/hello1234/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:145:48)
at Protocol.handshake (/home/hello1234/public_html/myapp/node_modules/mysql/lib/protocol/Protocol.js:52:23)
at Connection.connect (/home/hello1234/public_html/myapp/node_modules/mysql/lib/Connection.js:130:18)
at update_infos_all_users (/home/hello1234/public_html/myapp/app.js:570:9)
at Job.job (/home/westudec/public_html/myapp/app.js:1566:3)
at Job.invoke (/home/westudec/public_html/myapp/node_modules/node-schedule/lib/schedule.js:172:10)
at Timeout._onTimeout (/home/hello1234/public_html/myapp/node_modules/node-schedule/lib/schedule.js:542:11)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5) code: 'PROTOCOL_PACKETS_OUT_OF_ORDER', fatal: true }
The weird thing is that all work good on my computer.
Does someone have an idea ?
Thanks
Am trying to connect to a Mysql remote server using nodejs + selenium-webdriver.
The host am trying to connect is this: phpmyadmin.locaweb.com.br
If you acess this site, you will be able to see 3 fields to complete: Server,
User and Pass.
In my code, i do not know how to include the "Server". Looking in the web, i found the "localAdress" to pass as connection option, but is not working.
What i got so far:
//DB - config
var con = mysql.createConnection({
connectionLimit : 10,
host: "phpmyadmin.locaweb.com.br",
localAddress: "*****.mysql.dbaas.com.br",
user: "******",
password: "******",
port: 3306,
database: "*****"
});
con.connect(function(err){
if(err){
console.log('Error connecting to Db');
console.log(err);
return;
}
console.log('Connection established');
});
Error:
Error connecting to Db
{ Error: connect ETIMEDOUT
at Connection._handleConnectTimeout (C:\Users\User\Desktop\Projects\node_modules\mysql\lib\Connection.js:425:13)
at Socket.g (events.js:292:16)
at emitNone (events.js:86:13)
at Socket.emit (events.js:185:7)
at Socket._onTimeout (net.js:338:8)
at ontimeout (timers.js:386:14)
at tryOnTimeout (timers.js:250:5)
at Timer.listOnTimeout (timers.js:214:5)
--------------------
at Protocol._enqueue (C:\Users\User\Desktop\Projects\node_modul
es\mysql\lib\protocol\Protocol.js:141:48)
at Protocol.handshake (C:\Users\User\Desktop\Projects\node_modu
les\mysql\lib\protocol\Protocol.js:52:41)
at Connection.connect (C:\Users\User\Desktop\Projects\node_modu
les\mysql\lib\Connection.js:136:18)
at Object.<anonymous> (C:\Users\User\Desktop\Projects\status.js
:17:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
errorno: 'ETIMEDOUT',
code: 'ETIMEDOUT',
syscall: 'connect',
fatal: true }
I am running a server on AWS EC2 instance on ubuntu using node.js and MYSQL.It was working fine for 3 days, suddenly it stopped working.
On Googling i found that was due to lost connection in MYSQL DB. But could not find the exact cause of the fatal.
I am using following code for MYSQL connection
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : process.env.DB_PASSWORD
});
connection.query('USE MY_DB');
And for querying like this
app.get('/user', function(req, res){
connection.query('SELECT * FROM movie', function(err, rows){
var users = {"users" : rows};
res.send(users);
});
});
And log for the fatal:
2017-01-20T00:22:23.721Z - [31merror[39m: GET /users : Error: ER_SERVER_SHUTDOWN: Server shutdown in progress
at Query.Sequence._packetToError (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/sequences/Sequence.js:52:14)
at Query.ErrorPacket (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/sequences/Query.js:83:18)
at Protocol._parsePacket (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:280:23)
at Parser.write (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Parser.js:74:12)
at Protocol.write (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:39:16)
at Socket.<anonymous> (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:109:28)
at emitOne (events.js:96:13)
at Socket.emit (events.js:188:7)
at readableAddChunk (_stream_readable.js:176:18)
at Socket.Readable.push (_stream_readable.js:134:10)
--------------------
at Protocol._enqueue (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Connection.query (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:214:25)
at /home/ubuntu/myserver/myserver.js:125:14
at Layer.handle [as handle_request] (/home/ubuntu/myserver/node_modules/express/lib/router/layer.js:95:5)
at next (/home/ubuntu/myserver/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/ubuntu/myserver/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/ubuntu/myserver/node_modules/express/lib/router/layer.js:95:5)
at /home/ubuntu/myserver/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/home/ubuntu/myserver/node_modules/express/lib/router/index.js:330:12)
at next (/home/ubuntu/myserver/node_modules/express/lib/router/index.js:271:10)
one more log:
2017-01-20T00:22:24.189Z - [31merror[39m: deleteRecords : Error: connect ECONNREFUSED 127.0.0.1:3306
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
--------------------
at Protocol._enqueue (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:141:48)
at Protocol.handshake (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:52:41)
at Connection.connect (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:136:18)
at Connection._implyConnect (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:467:10)
at Connection.query (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:212:8)
at Object.<anonymous> (/home/ubuntu/myserver/myserver.js:21:12)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
2017-01-20T00:22:28.135Z - [31merror[39m: GET /users : Error: Cannot enqueue Query after fatal error.
at Protocol._validateEnqueue (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:199:16)
at Protocol._enqueue (/home/ubuntu/myserver/node_modules/mysql/lib/protocol/Protocol.js:135:13)
at Connection.query (/home/ubuntu/myserver/node_modules/mysql/lib/Connection.js:214:25)
at /home/ubuntu/myserver/myserver.js:125:14
at Layer.handle [as handle_request] (/home/ubuntu/myserver/node_modules/express/lib/router/layer.js:95:5)
at next (/home/ubuntu/myserver/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/home/ubuntu/myserver/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/home/ubuntu/myserver/node_modules/express/lib/router/layer.js:95:5)
at /home/ubuntu/myserver/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/home/ubuntu/myserver/node_modules/express/lib/router/index.js:330:12)
I want to know the exact issue and the solution. Any help is appreciated.