From:  pear-qa@lists.php.net ("glen@pld-linux.org")
Date:  02 May 2018 02:06:10 Hong Kong Time
Newsgroup:  news.php.net/php.pear.bugs
Subject:  

[PEAR-BUG] Bug #20974 [Com]: reconnect is not indefinite

NNTP-Posting-Host:  null

Edit report at https://pear.php.net/bugs/bug.php?id=20974&edit=1

 ID:               20974
 Comment by:       glen at pld-linux dot org
 Reported By:      glen at delfi dot ee
 Summary:          reconnect is not indefinite
 Status:           Closed
 Type:             Bug
 Package:          Net_SmartIRC
 Package Version:  1.1.8
 PHP Version:      5.5.30
 Assigned To:      garrettw
 Roadmap Versions: 
 New Comment:

seems to gain the needed functionality i need to reorder commands:

        $irc->setAutoRetryMax(0);
        $irc->setAutoRetry(true);


setAutoRetryMax resets setAutoRetry to false somewhy


Previous Comments:
------------------------------------------------------------------------

[2015-11-10 20:29:41] garrettw

-Status:      Open
+Status:      Closed
-Assigned To:
+Assigned To: garrettw
This bug has been fixed in SVN.

If this was a documentation problem, the fix will appear on pear.php.net
by the end of next Sunday (CET).

If this was a problem with the pear.php.net website, the change should
be live shortly.

Otherwise, the fix will appear in the package's next release.

Thank you for the report and for helping us make PEAR better.

Setting autoRetryMax to 0 should indeed imply endless retries, so I've
corrected that. You can use 0 now.

Also I've changed the way reconnect() and connect() interact, so they
won't keep calling each other endlessly. It just loops now.

Let me know if it works for you.

------------------------------------------------------------------------

[2015-10-26 22:34:14] glen

i've workarounded in my bot to do "userspace" reconnecting. something
like:

        // reconnect is poorly designed, do not use it
        // @see https://pear.php.net/bugs/bug.php?id=20974
        $irc->setAutoRetry(false);
        $irc->setAutoRetryMax(PHP_INT_MAX);
        $irc->setReconnectDelay(1000);

        $irc->connect($config['hostname'], $config['port']);
        $irc->login($config['nickname'], $config['realname']);

        $this->joinChannels($irc);

        while (!$this->shutdown) {
            $irc->listen();
            $irc->reconnect();
        }
        $irc->disconnect();

------------------------------------------------------------------------

[2015-10-26 22:19:11] glen

Description:
------------
it's impossible to configure it to retry forever

first, there's no way setting it such, i tried "0", but that 
disabled reconnect at all, so i set PHP_INT_MAX. but due the 
way reconnect is designed, php runs out of recursion limit:


Oct 27 00:15:59 SmartIRC.php(1111) retry #48
PHP Fatal error:  Maximum function nesting level of '100' 
reached, aborting! in /usr/share/pear/Net/SmartIRC.php on 
line 909
PHP Stack trace:
PHP   1. {main}() /usr/share/eventum/bin/irc-bot.php:0
PHP   2. Eventum_Bot->run() /usr/share/eventum/bin/irc-
bot.php:69
PHP   3. Net_SmartIRC->connect() 
/usr/share/eventum/lib/eventum/irc/Eventum_Bot.php:222
PHP   4. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP   5. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP   6. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP   7. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP   8. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP   9. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  10. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  11. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  12. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  13. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  14. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  15. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  16. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  17. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  18. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  19. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  20. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  21. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  22. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  23. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  24. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  25. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  26. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
PHP  27. Net_SmartIRC->connect() 
/usr/share/pear/Net/SmartIRC.php:1208
PHP  28. Net_SmartIRC->reconnect() 
/usr/share/pear/Net/SmartIRC.php:1112
....

------------------------------------------------------------------------


-- 
Edit this bug report at https://pear.php.net/bugs/bug.php?id=20974&edit=1