Gayathri Gayathri - 1 year ago 538
SQL Question

nodejs to mysql connection error

I'm getting error :
error:Error: Handshake inactivity timeout

Answer Source

Use Connection Pool:

var mysql = require('mysql');
var pool  = mysql.createPool({
  host     : '',
  user     : 'bob',
  password : 'secret'

pool.getConnection(function(err, connection) {
  // Use the connection
  connection.query( 'SELECT something FROM sometable', function(err, rows) {
    // And done with the connection.

    // Don't use the connection here, it has been returned to the pool.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download