Hi Following is error what I am getting:-
PDOException: SQLSTATE[HY000]: General error: 20003 Adaptive Server connection timed out [20003] (severity
6) [(null)] in /var/www/html/web/vendor/laravel/framework/src/Illuminate/Database/Connection.php:335
Before I was trying to fetch 5k records, I thot query is taking longer time but even I reduce a limit to 100 then also getting same error. My net connection is high speed and server hardware is highly configured.
I have tried all the solution given on below link and I am getting success but when my script runs facing above issue.
My script run well locally. But facing issue when I promoted code to dev.
The problem seems to be related to the execution time for your query.
I was having this same issue and it was solved after I've changed the timeout settings at config/databases.php
file.
Use the code below:
'options' => [
PDO::ATTR_TIMEOUT => 300, // up to 5 minutes
],
The complete config should be:
'sqlsrv' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'prefix' => '',
'options' => [
PDO::ATTR_TIMEOUT => 300,
],
],