From 7afbb6455fbde092ba9075d6771fd5bf61ec9828 Mon Sep 17 00:00:00 2001 From: deutor Date: Sat, 3 Sep 2016 15:54:37 +0200 Subject: [PATCH] feature: IRCBot re-connection back-off (#4322) --- LibreNMS/IRCBot.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/LibreNMS/IRCBot.php b/LibreNMS/IRCBot.php index c4452e183b..1d5959c1f9 100644 --- a/LibreNMS/IRCBot.php +++ b/LibreNMS/IRCBot.php @@ -372,7 +372,7 @@ class IRCBot return die(); } - $this->log('Trying to connect to '.$this->server.':'.$this->port.($this->ssl ? ' (SSL)' : '')); + $this->log('Trying to connect ('.($try + 1).') to '.$this->server.':'.$this->port.($this->ssl ? ' (SSL)' : '')); if ($this->socket['irc']) { fclose($this->socket['irc']); } @@ -392,6 +392,13 @@ class IRCBot } if (!is_resource($this->socket['irc'])) { + if ($try < 5) { + sleep(5); + } elseif ($try < 10) { + sleep(60); + } else { + sleep(300); + } return $this->connect($try + 1); } else { stream_set_blocking($this->socket['irc'], false);