1

Maybe I've updated my node version or other reasons,I fail to run my code. But why?

My code is as follow.

let db = mysql.createPool({
    host: 'xxx',
    port: 'xxx',
    user: 'xxx',
    password: 'xxx',
    database: 'xxx'
});

new Promise((resovle,reject) => {
    db.query("select * from bill;", (err,data) => {
        resovle(err,data);
    });
}).then((err,data) => {
    console.log(err);
    console.log(data);
});

and here is the output:

{ Error: Handshake inactivity timeout
    at Handshake.<anonymous> (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\protocol\Protocol.js:160:17)
    at Handshake.emit (events.js:182:13)
    at Handshake._onTimeout (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\protocol\sequences\Sequence.js:124:8)
    at Timer._onTimeout (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\protocol\Timer.js:32:23)        
    at ontimeout (timers.js:436:11)
    at tryOnTimeout (timers.js:300:5)
    at listOnTimeout (timers.js:263:5)
    at Timer.processTimers (timers.js:223:10)
    --------------------
    at Protocol._enqueue (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\protocol\Protocol.js:144:48)   
    at Protocol.handshake (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\protocol\Protocol.js:51:23)   
    at PoolConnection.connect (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\Connection.js:116:18)     
    at Pool.getConnection (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\Pool.js:48:16)
    at Pool.query (C:\Users\Administrator\Desktop\sfinder\server\node_modules\_mysql@2.18.1@mysql\lib\Pool.js:202:8)
    at Promise (C:\Users\Administrator\Desktop\sfinder\server\server.js:17:8)
    at new Promise (<anonymous>)
    at Object.<anonymous> (C:\Users\Administrator\Desktop\sfinder\server\server.js:16:1)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
  code: 'PROTOCOL_SEQUENCE_TIMEOUT',
  fatal: true,
  timeout: 10000 }
undefined

and the node environments are: (1) node-v v10.15.0 (2)express --version 4.16.0 (3)mysql(middleware) ^2.18.1

royalpioneer
  • 33
  • 1
  • 4
  • 1
    Looks like the database is not connected. – Niklas E. Apr 06 '20 at 10:29
  • 2
    this might help you https://stackoverflow.com/questions/35553432/error-handshake-inactivity-timeout-in-node-js-mysql-module – Sandeep Patel Apr 06 '20 at 10:50
  • Yeah,it sometimes can help.But there is still one trouble that sometimes it will request an api for a long long long time so that we user can think the application is dead. So, may I continue to using the mysql middleware? Is there a solution or another valid express middleware? – royalpioneer Apr 06 '20 at 14:25

0 Answers0