title: How can I keep a constant MySQL connection alive in NodeJS
body: <p>I'm currently developing Discord Bot, for data storing I'm using MySQL, but after some hours de connection dies. I was wondering if someone has a clue on how to do this. This the way I currently connect:</p>
  
  <pre><code>// Initalise Variables
  var config;
  var mysql, conn;
  var fs;
  
  try {
      // External Packages
      fs = require('fs');
      config = require('./config.json');
      mysql = require('mysql');
  
      // Connection Setup
      conn = mysql.createConnection({
          host: config.mysql.host,
          user: config.mysql.user,
          password: config.mysql.password,
          database: config.mysql.database
      });
      conn.connect();
  } catch (e) {
      console.error(e);
  }
  </code></pre>