Edit report at https://pear.php.net/bugs/bug.php?id=12539&edit=1
ID: 12539
Updated by: [email protected]
Reported By: mario at mafiareturns dot com
Summary: Flaw in timeout detection.
-Status: Assigned
+Status: Closed
Type: Bug
Package: Net_SmartIRC
Operating System: Linux
Package Version: 1.0.0
PHP Version: 5.2.4
Assigned To: garrettw
Roadmap Versions:
New Comment:
-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.
Previous Comments:
------------------------------------------------------------------------
[2014-02-05 09:05:05] garrettw
-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.
------------------------------------------------------------------------
[2011-03-28 12:11:00] garrettw
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);
}
}
}
------------------------------------------------------------------------
[2008-03-16 10:32:08] noia
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 <[email protected]>';
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);
}
}
?>
------------------------------------------------------------------------
[2007-11-28 16:52:05] meebey
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.
------------------------------------------------------------------------
[2007-11-28 00:09:01] topnotcher
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)
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=12539&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.