| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentForm\Framework\Database; |
| 4 |
|
| 5 |
use Throwable; |
| 6 |
use FluentForm\Framework\Support\Str; |
| 7 |
|
| 8 |
trait DetectsLostConnections |
| 9 |
{ |
| 10 |
/** |
| 11 |
* Determine if the given exception was caused by a lost connection. |
| 12 |
* |
| 13 |
* @param \Throwable $e |
| 14 |
* @return bool |
| 15 |
*/ |
| 16 |
protected function causedByLostConnection(Throwable $e) |
| 17 |
{ |
| 18 |
$message = $e->getMessage(); |
| 19 |
|
| 20 |
return Str::contains($message, [ |
| 21 |
'server has gone away', |
| 22 |
'Server has gone away', |
| 23 |
'no connection to the server', |
| 24 |
'Lost connection', |
| 25 |
'is dead or not enabled', |
| 26 |
'Error while sending', |
| 27 |
'decryption failed or bad record mac', |
| 28 |
'server closed the connection unexpectedly', |
| 29 |
'SSL connection has been closed unexpectedly', |
| 30 |
'Error writing data to the connection', |
| 31 |
'Resource deadlock avoided', |
| 32 |
'Transaction() on null', |
| 33 |
'child connection forced to terminate due to client_idle_limit', |
| 34 |
'query_wait_timeout', |
| 35 |
'reset by peer', |
| 36 |
'Physical connection is not usable', |
| 37 |
'TCP Provider: Error code 0x68', |
| 38 |
'ORA-03114', |
| 39 |
'Packets out of order. Expected', |
| 40 |
'Adaptive Server connection failed', |
| 41 |
'Communication link failure', |
| 42 |
'connection is no longer usable', |
| 43 |
'Login timeout expired', |
| 44 |
'SQLSTATE[HY000] [2002] Connection refused', |
| 45 |
'running with the --read-only option so it cannot execute this statement', |
| 46 |
'The connection is broken and recovery is not possible. The connection is marked by the client driver as unrecoverable. No attempt was made to restore the connection.', |
| 47 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again', |
| 48 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known', |
| 49 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for', |
| 50 |
'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: EOF detected', |
| 51 |
'SQLSTATE[HY000] [2002] Connection timed out', |
| 52 |
'SSL: Connection timed out', |
| 53 |
'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.', |
| 54 |
'Temporary failure in name resolution', |
| 55 |
'SQLSTATE[08S01]: Communication link failure', |
| 56 |
'SQLSTATE[08006] [7] could not connect to server: Connection refused Is the server running on host', |
| 57 |
'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: No route to host', |
| 58 |
'The client was disconnected by the server because of inactivity. See wait_timeout and interactive_timeout for configuring this behavior.', |
| 59 |
'SQLSTATE[08006] [7] could not translate host name', |
| 60 |
'TCP Provider: Error code 0x274C', |
| 61 |
'SQLSTATE[HY000] [2002] No such file or directory', |
| 62 |
'SSL: Operation timed out', |
| 63 |
'Reason: Server is in script upgrade mode. Only administrator can connect at this time.', |
| 64 |
'Unknown $curl_error_code: 77', |
| 65 |
'SSL: Handshake timed out', |
| 66 |
'SSL error: sslv3 alert unexpected message', |
| 67 |
'unrecognized SSL error code:', |
| 68 |
'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it', |
| 69 |
'SQLSTATE[HY000] [2002] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', |
| 70 |
'SQLSTATE[HY000] [2002] Network is unreachable', |
| 71 |
'SQLSTATE[HY000] [2002] The requested address is not valid in its context', |
| 72 |
'SQLSTATE[HY000] [2002] A socket operation was attempted to an unreachable network', |
| 73 |
'SQLSTATE[HY000] [2002] Operation now in progress', |
| 74 |
'SQLSTATE[HY000] [2002] Operation in progress', |
| 75 |
'SQLSTATE[HY000]: General error: 3989', |
| 76 |
'went away', |
| 77 |
'No such file or directory', |
| 78 |
'server is shutting down', |
| 79 |
'failed to connect to', |
| 80 |
'Channel connection is closed', |
| 81 |
'Connection lost', |
| 82 |
'Broken pipe', |
| 83 |
'SQLSTATE[25006]: Read only sql transaction: 7', |
| 84 |
]); |
| 85 |
} |
| 86 |
} |
| 87 |
|