From:  pear-qa@lists.php.net ("glen@delfi.ee")
Date:  27 Oct 2015 06:34:15 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@delfi.ee
 Reported By:      glen at delfi dot ee
 Summary:          reconnect is not indefinite
 Status:           Open
 Type:             Bug
 Package:          Net_SmartIRC
 Package Version:  1.1.8
 PHP Version:      5.5.30
 Roadmap Versions: 
 New Comment:

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();


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

[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