Long running server processes that are accessing the database will run into connection timeout errors if the period of inactivity on the connection is longer than the setting in the database. Although this is typically only an issue with a command line script, in this script we will use a normal MVC web application. We will first demonstrate the issue by allowing the database connection to timeout due to inactivity and then next we will create a solution to this.
This recipe uses the Phalcon Developer Tools, which we will use to set up a project skeleton. We will need a database to test our reconnection plugin.
Follow these steps to complete this recipe:
We need to have an application skeleton for experimentation. If you already have such an application, you can skip this step. Create a project skeleton using the
simple
template:phalcon project reconnect simple
Now point the web browser at the root directory of the project. There should be...