C:\Users\horn1\Desktop\node.js\ the>node express.js{error:handshake inactivity Timeout at handshake.<anonymous> (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\protocol\protocol.js:164: -) at Emitnone (events.js: the: -) at Handshake.emit (events.js:207:7) at Handshake._ontimeout (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\protocol\sequences\sequence.js:129:8) at OnTimeOut (timers.js:469: One) at Tryontimeout (timers.js:304:5) at Timer.listontimeout (timers.js: the:5) --------------------At Protocol._enqueue (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\protocol\protocol.js:145: -) at Protocol.handshake (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\protocol\protocol.js: the: at) at Poolconnection.connect (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\connection.js: the: -) at Pool.getconnection (C:\Users\horn1\Desktop\node.js\ the\node_modules\mysql\lib\pool.js: -: -) at Incomingmessage.<anonymous> (C:\Users\horn1\Desktop\node.js\ the\express.js: in:8) at Emitone (events.js: the: -) at Incomingmessage.emit (events.js: About:7) at IncomingMessage.Readable.read (_stream_readable.js:478:Ten) at Flow (_stream_readable.js:849: the) at Resume_ (_stream_readable.js:831:3) Code:'Protocol_sequence_timeout', Fatal:true, timeout:10000}
The code is as follows:
' Use strict ';varExpress=require (' Express ');varFs=require (' FS ');varQuerystring=require (' QueryString ');varHttp=require (' http ');varapp=Express ();varMysql=require (' MySQL ');varPool=Mysql.createpool ({host:' 192.168.80.129 ',//database on local virtual machine, can connect port with Mysql-front:' 3306 ', Database:' Test ', User:' Root ', Password:' 12345678 ', timeout:1000000000, ConnectTimeout:1000000000,}); App.get ('/index.html ',function(req,res) {Res.writehead (200,{' content-type ': ' text/html '}); varFile=fs.createreadstream (' index.html '); File.pipe (res);}); App.post ('/index.html ',function(req,res) {Req.on (' Data ',function(data) {varobj=Querystring.parse (data.tostring ()); Pool.getconnection (function(err,connection) {if(Err) {Res.send (' Can not connect to MYSQL DB '); Console.log (ERR); }Else{ varstr; Connection.query (' INSERT into EMP set? ', {name:obj.name},function(err,result) {if(err) {str= ' Insert failed '; }Else{str= "Insert Succeed"; } connection.release (); Res.send (str); }) } }); });}); App.listen (3333, "127.0.0.1");
The following error occurred connecting to MySQL database using Nodejs mysql module