Skip to content

Commit 8e0b234

Browse files
committed
Add retry connection.
1 parent 0b83cb2 commit 8e0b234

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

.gitattributes

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/.coveralls.yml export-ignore
2+
/.gitattributes export-ignore
3+
/.github/ export-ignore
4+
/.gitignore export-ignore
5+
/.travis.yml export-ignore
6+
/.travis/ export-ignore
7+
/phpunit.xml export-ignore
8+
/tests/ export-ignore

src/MySQLReplication/BinLog/BinLogServerInfo.php

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public static function parsePackage(string $data, string $version): BinLogServer
1717
{
1818
$i = 0;
1919
$length = strlen($data);
20+
$serverInfo = [];
2021
$serverInfo['protocol_version'] = ord($data[$i]);
2122
++$i;
2223

src/MySQLReplication/MySQLReplicationFactory.php

+7-2
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,9 @@ public function run(): void
163163
}
164164
} catch (\Throwable $e) {
165165
$this->logger->warning("[MysqlReplication] Connect error:" . $e->getMessage(), ['exception' => $e]);
166-
$this->socket->close();
166+
if (method_exists($this->socket, 'close')) {
167+
$this->socket->close();
168+
}
167169
sleep(1);
168170
continue;
169171
}
@@ -175,7 +177,10 @@ public function run(): void
175177
}
176178
} catch (SocketException $e) {
177179
$this->logger->warning("[MysqlReplication] Connection lost: " . $e->getMessage(), ['exception' => $e]);
178-
$this->socket->close();
180+
181+
if (method_exists($this->socket, 'close')) {
182+
$this->socket->close();
183+
}
179184
}
180185
}
181186
}

src/MySQLReplication/Socket/Socket.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __destruct()
1212
$this->close();
1313
}
1414

15-
public function close()
15+
public function close(): void
1616
{
1717
if ($this->isConnected()) {
1818
socket_shutdown($this->socket);

0 commit comments

Comments
 (0)