Closed harishdurga closed 4 years ago
If you want to reuse existing connections you shouldn't add DatabaseServiceProvider to the "providers" section.
For your case I recommend to configure a multiple database connections in the config/database.php
file and choose needed connection from the application layer.
Please provide your PHP and Swoole version. (
php -v
andphp --ri swoole
) PHP 7.2.26-1+ubuntu18.04.1+deb.sury.org+1 and swoole version 4.4.14Please provide your Laravel/Lumen version. Laravel 5.8
Which release version of this package are you using? 2.6.66
What did you do? If possible, provide a recipe for reproducing the error. I have added
Illuminate\Database\DatabaseServiceProvider::class
to the providers array. After this every request is creating a new client connection to the database.What did you expect to see? Connection reuse, or connections getting closed automatically once the request is completed.
What did you see instead? Each request is creating new database connection(s) and old connections are still there. I can see lot of connections for the Mysql server from the work bench.If i comment this
Illuminate\Database\DatabaseServiceProvider::class
then the issue is not present. My requirement is to connect to different databases based on the request parameters.