X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/blobdiff_plain/a74388255ced48e9dac0490acc76b782f74cc2c8..HEAD:/src/callnotifier/Source/Remote.php diff --git a/src/callnotifier/Source/Remote.php b/src/callnotifier/Source/Remote.php index 39b042c..be7604f 100644 --- a/src/callnotifier/Source/Remote.php +++ b/src/callnotifier/Source/Remote.php @@ -13,9 +13,19 @@ class Source_Remote public function run() { - $this->connect($this->config->host, $this->config->port); - $this->init(); - $this->loop(); + do { + try { + $tryAgain = false; + $this->connect($this->config->host, $this->config->port); + $this->init(); + $this->loop(); + } catch (Exception_ConnectionReset $e) { + $tryAgain = true; + //connection is refused directly after a connection reset + //hopefully waiting a bit will help + sleep(10); + } + } while ($tryAgain); $this->disconnect(); } @@ -64,6 +74,11 @@ class Source_Remote function read_response() { $res = socket_read($this->socket, 2048, PHP_NORMAL_READ); + if ($res === false) { + //handle "Connection reset by peer" that appears nightly since + // version 4.0N + throw new Exception_ConnectionReset(); + } return substr($res, 2, -1); }