Skip to content
This repository was archived by the owner on Oct 30, 2024. It is now read-only.

Commit c765fe5

Browse files
committed
Check for error on connect and on first ping
1 parent e527a64 commit c765fe5

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/Connection.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,17 +235,19 @@ public function connect($timeout = null)
235235
{
236236
$this->timeout = $timeout;
237237
$this->streamSocket = $this->getStream($this->options->getAddress(), $timeout);
238+
238239
$msg = 'CONNECT '.$this->options;
239240
$this->send($msg);
240-
241-
$response = $this->receive();
241+
$connect_response = $this->receive();
242+
if (strpos($connect_response, '-ERR')!== false) {
243+
throw new \Exception("Failing connection: $connect_response");
244+
}
242245

243246
$this->ping();
244-
$response = $this->receive();
245-
246-
if ($response !== "PONG") {
247-
if (strpos($response, '-ERR')!== false) {
248-
throw new \Exception("Failing connection: $response");
247+
$ping_response = $this->receive();
248+
if ($ping_response !== "PONG") {
249+
if (strpos($ping_response, '-ERR')!== false) {
250+
throw new \Exception("Failing on first ping: $ping_response");
249251
}
250252
}
251253
}

0 commit comments

Comments
 (0)