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.
[https://blogs.msdn.microsoft.com/sql_protocols/2008/04/30/steps-to-troubleshoot-sql-connectivity-issues/][1]
My script run well locally. But facing issue when I promoted code to dev.
I've dug into this a little today, I don't believe its any problem with Azure SQL, but for some reason, a dead connection from any SQL Server is reported as a timeout. You need to actually check DEADPROC in the err_handler and then return INT_EXIT instead
There can be various causes that can turn out to be the potential reasons for the connection timed out error. Some of these causes are mentioned below: Slow Internet Connection: Slow Internet connection is one of the possible reasons for the error.
What Is Err_Connection_Timed_Out Error The connection timed out error isn’t a harmful error or any infected file that can cause harm to your system. This message is mainly the notification that the system is unable to set up a connection with the server.
Then FreeTDS/Tiny TDS go in a loop with the server, responding with INT_CONTINUE. The server responds again with the 20003 error. They back and forth until the unicorn master is fed up and reaps the process.
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,
],
],
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With