Skip to content

Commit

Permalink
Attempt to catch reset by peer errors as well
Browse files Browse the repository at this point in the history
  • Loading branch information
peldax authored Oct 24, 2022
1 parent b73f255 commit cd2aff3
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Bridge/Nette/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@

final class Connection extends \Nette\Database\Connection
{
public function query(string $sql, ...$params): \Nette\Database\ResultSet
public function connect() : void
{
try {
parent::connect();
} catch (\PDOException $e) {
if (\str_contains($e->getMessage(), 'reset by peer')) {
parent::connect(); // retry
}

throw $e;
}
}

public function query(string $sql, ...$params) : \Nette\Database\ResultSet
{
try {
return parent::query($sql, $params);
Expand Down

0 comments on commit cd2aff3

Please sign in to comment.