I have project on php (Yii2) and DB (PDO).
I have an exident. DB in project is not critical, project works with external API.
I have connection timeout - 5 sec.
return [
'class' => 'yii\db\Connection',
'dsn' => 'mysql:host=xx.xx.xx.xx;dbname=db_name',
'username' => 'user,
'password' => '',
'charset' => 'utf8',
'attributes' => [
PDO::ATTR_TIMEOUT => 5
]
];
But it is timeout on connection to DB.
But if I already connected to DB, server down in swap and I need wait until receive answer as long as DB will get up, even if timeout only 5 sec.
How I can set common timeout? That if I will not receive answer in 5 sec, drop connection.