Nodejs mysql - PROTOCOL_SEQUENCE_TIMEOUT - how to properly close a connection
<p>I am trying to use the nodejs-mysql module from felixge. What I need to do is to make an one off query, get the result and end the connection. </p>

<p>As you can see bellow I set up my connection, query and on results I try to end the connection. Now the problem is although I send a ComQuitPacket it doesn't disconnect properly and waits till the database connection times out. Btw the data are received correctly and fine.</p>

<p>I run a SHOW FULL PROCESSLIST on the database but there is no connection being shown AFTER I receive the data. </p>

<p>Am I ending the connection in a wrong way? I also tried removing the callback and not ending the response but nothing.</p>

<p>There is ticket which is now closed in github <a href="https://github.com/felixge/node-mysql/issues/1223" rel="nofollow">https://github.com/felixge/node-mysql/issues/1223</a></p>

<p>By the way I am using ClearDB MySQL :: Database from Heroku!
Also I am using node v5.4.0</p>

<pre><code>var connection = mysql.createConnection({
 debug: true,
 host: enhancedWidgetModel.dataSource.mysql.host,
 user: enhancedWidgetModel.dataSource.mysql.username,
 password: enhancedWidgetModel.dataSource.mysql.password,
 database: enhancedWidgetModel.dataSource.mysql.database
})

  connection.query(enhancedWidgetModel.query, function (err, rows, fields) {
    connection.end(function (err) {
      if (err) {
        console.log(err)
      } else {
        console.log('ended')
      }
    })
    if (err) {
      console.log(err)
      callback({
        data: null,
        msg: 'error',
        code: 'error'
      })
    } else if (rows) {
      callback({
        data: rows,
        msg: 'acknowledged',
        code: 'success'
      })
    }
  })


&lt;-- EofPacket
EofPacket {
  fieldCount: 254,
  warningCount: 0,
  serverStatus: 34,
  protocol41: true }

--&gt; ComQuitPacket
ComQuitPacket { command: 1 }

{ [Error: Quit inactivity timeout]
  code: 'PROTOCOL_SEQUENCE_TIMEOUT',
  fatal: true,
  timeout: 30000 }
</code></pre>

<p>Raised an issue with the github repo: <a href="https://github.com/felixge/node-mysql/issues/1334" rel="nofollow">https://github.com/felixge/node-mysql/issues/1334</a></p>