title: PHP Socket Server Loses Connection to MySQL Overnight
body: <p>I've got a PHP socket server that sits around waiting for connections, then talks to a database to resolve them. It works fine when I'm testing, but then when I leave it sitting around, the next morning it no longer talks to the database.</p>
  
  <p>When I look at my logs, I see this:</p>
  
  <pre><code>200327 11:54:37    24 Connect   dbuser@localhost as anonymous on dbname
         24 Quit  
  </code></pre>
  
  <p>Where I'm expecting to see something more like this:</p>
  
  <pre><code>200327 11:54:20    23 Connect   dbuser@localhost as anonymous on dbname
             23 Query SELECT * FROM table1 WHERE num=4
             23 Query SELECT * FROM table2 WHERE num='4' AND info='deleted'
             23 Query SELECT * FROM table3 WHERE num='4'
             23 Quit  
  </code></pre>
  
  <p>But for some reason, after the server has been running for a while, the queries never go through after that initial connection.</p>
  
  <p>The only thing I can think of is that maybe my PDO object is somehow timing out, as I create it once when I fire up the server.</p>
  
  <pre><code>$dbh = new PDO($dbName,$dbUser,$dbPass);
  </code></pre>
  
  <p>Any thoughts on what might be going on, and if creating the PDO object at the start of the process isn't correct, how to better manage that resource?</p>
  
  <p>PHP is PHP 7.0.33, MySQL is 10.1.44-MariaDB-0+deb9u1 Debian 9.11.</p>