I am having a strange issue that's been bugging me for days: I am using a php websocket script for an intranet site to alert staff about certain things. it was a cheap and fairly easy to implement solution and it works fine. however, I am having to restart the server every morning.
as the php code runs on an endless loop and every task is run in sequence rather than simultaneously, I assumed that one persistent connection to the DB would suffice, so I just open a connection right in the beginning of the code with a $GLOBALS variable and reuse it over and over. it works fine until the next morning when all requests will come back as false. the connection is still alive. error catchers such as "->connect_error" and "->connect_stat()" won't return errors.
apparently MySQL runs a self-update check every night at midnight. I'm not sure this is what's causing problems but I am hoping I won't have to disable this feature.
the only way I managed to work around this issue was to send a query that can only return a positive response. if it doesn't than it shuts and re-opens the connection. it doesn't seem smart to me. there has to be a way to detect when the connection becomes unreliable.
I'm using the latest versions of PHP and MySQL.
any ideas?