Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.1.14

Bug #12539 Flaw in timeout detection.
Submitted: 2007-11-28 05:09 UTC
From: topnotcher Assigned: garrettw
Status: Closed Package: Net_SmartIRC (version 1.0.0)
PHP Version: 5.2.4 OS: Linux
Roadmaps: 1.1.0    
Subscription  


 [2007-11-28 05:09 UTC] topnotcher (Greg Bowser)
Description: ------------ Summary: When auto reconnect is on, SmartIRC disconnects if it doesn't receive for 300 seconds. Problem: the code expects that the server will send a ping in that amount of time, but this is not necessarily the case; an active client (i.e. dots of sending) may not be pinged because the server knows he is alive. I encountered a problem where I was sending lots of information to a log channel, but not getting any data sent to me (as is to be expected). SmartIRC detected a receive timeout and reconnected. Possible Solution: PING the server after 1/2 the receive timeout (in this case, 150 seconds). If a response is received, then the _lastrx is set. Else, a timeout should be detected at 300 seconds (150 seconds after the ping is sent)

Comments

 [2007-11-28 21:52 UTC] meebey (Mirco Bauer)
Indeed this is a flaw in the timeout detection in Net_SmartIRC. I solved this issue in SmartIrc4net (a C# port of Net_SmartIRC) by using an active detection/pinger instead of a passive one. Different IRCd implementations handle the ping/pong ritual differently, and the passive approach is not reliable enough.
 [2008-03-16 14:32 UTC] noia (Bjorn Soldal)
I solved this issue with a simple module as seen below, this should function for most IRCds' but I can't guarantee anything... <?php class Cygnus_Orange_module_ping { var $name = 'ping'; var $version = '$Revision: 1.0.0.1 $'; var $description = 'This module functions as an active-pinging system'; var $author = 'Noia <wasting.my.time@gmail.com>'; var $license = 'GPL'; var $timeout = 120; var $pingFrequency = 20; // Supplied in seconds function module_init(&$irc) { $irc->registerTimehandler($this->pingFrequence*100, $this, 'pingCheck'); } function pingCheck(&$irc) { if (time()-$irc->_lastrx > $this->timeout) { $irc->reconnect(); $irc->_lastrx = time(); } else { $irc->_send('PING '.$irc->_address, SMARTIRC_CRITICAL); } } ?>
 [2011-03-28 16:11 UTC] garrettw (Garrett Whitehorn)
I implemented it a bit differently: (this is built to work with the patches I recently submitted) <?php class Net_SmartIRC_module_PingFix { public $name = 'PingFix'; public $version = '1.0'; public $description = 'An active-pinging system to keep the connection alive'; public $author = 'Garrett W.'; public $license = 'GPL'; private $irc; private $thid; function __construct (&$irc) { $this->irc = $irc; $this->thid = $this->irc->registerTimehandler($this->irc->_rxtimeout/8*1000, $this, 'pingCheck'); } function __destruct () { $this->irc->unregisterTimeid($this->thid); } function pingCheck (&$i,&$d) { if (time() - $this->irc->_lastrx > $this->irc->_rxtimeout) { $this->irc->reconnect(); $this->irc->_lastrx = time(); } elseif (time() - $this->irc->_lastrx > $this->irc->_rxtimeout/2) { $this->irc->_send('PING '.$this->irc->_address, SMARTIRC_CRITICAL); } } }
 [2014-02-05 14:05 UTC] garrettw (Garrett Whitehorn)
-Status: Verified +Status: Assigned -Assigned To: +Assigned To: garrettw
Going to add my code as a stock module for now, so at least the code will come with the package, even though people will have to load the module manually. I'm only marking it as assigned because the fix isn't built into the main code yet.
 [2014-09-03 15:19 UTC] garrettw (Garrett Whitehorn)
-Status: Assigned +Status: Closed
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.