| 148 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
namespace Illuminate\Database;
|
|
|
4 |
|
|
|
5 |
use Illuminate\Support\Str;
|
|
|
6 |
use Throwable;
|
|
|
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 |
'no connection to the server',
|
|
|
23 |
'Lost connection',
|
|
|
24 |
'is dead or not enabled',
|
|
|
25 |
'Error while sending',
|
|
|
26 |
'decryption failed or bad record mac',
|
|
|
27 |
'server closed the connection unexpectedly',
|
|
|
28 |
'SSL connection has been closed unexpectedly',
|
|
|
29 |
'Error writing data to the connection',
|
|
|
30 |
'Resource deadlock avoided',
|
|
|
31 |
'Transaction() on null',
|
|
|
32 |
'child connection forced to terminate due to client_idle_limit',
|
|
|
33 |
'query_wait_timeout',
|
|
|
34 |
'reset by peer',
|
|
|
35 |
'Physical connection is not usable',
|
|
|
36 |
'TCP Provider: Error code 0x68',
|
|
|
37 |
'ORA-03114',
|
|
|
38 |
'Packets out of order. Expected',
|
|
|
39 |
'Adaptive Server connection failed',
|
|
|
40 |
'Communication link failure',
|
|
|
41 |
'connection is no longer usable',
|
|
|
42 |
'Login timeout expired',
|
|
|
43 |
'SQLSTATE[HY000] [2002] Connection refused',
|
|
|
44 |
'running with the --read-only option so it cannot execute this statement',
|
|
|
45 |
'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.',
|
|
|
46 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Try again',
|
|
|
47 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known',
|
|
|
48 |
'SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for',
|
|
|
49 |
'SQLSTATE[HY000]: General error: 7 SSL SYSCALL error: EOF detected',
|
|
|
50 |
'SQLSTATE[HY000] [2002] Connection timed out',
|
|
|
51 |
'SSL: Connection timed out',
|
|
|
52 |
'SQLSTATE[HY000]: General error: 1105 The last transaction was aborted due to Seamless Scaling. Please retry.',
|
|
|
53 |
'Temporary failure in name resolution',
|
|
|
54 |
'SSL: Broken pipe',
|
|
|
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 |
]);
|
|
|
65 |
}
|
|
|
66 |
}
|