1
philroy
Site won't load when news feed is down
  • 2004/1/27 9:08

  • philroy

  • Friend of XOOPS

  • Posts: 107

  • Since: 2003/8/23


Hi all,

Previously, for a non-xoops site, I've been using this to pull RSS feeds...
http://magpierss.sourceforge.net/

It includes error checking and if it can't access a RSS feed that you've specified, it pops a litle error message on the page.

Just now with a test site I'm working on in Xoops, one of the sites that I get an RSS feed from using the Headlines module seems to have gone down. What's worse is that I can't now load my main page, as the site just sits there trying to find the feed, then hangs.

Is this because I have the cache switched off during testing and development? Or is there no error checking in the headlines module?

Phil

2
phlewis
Re: Site won't load when news feed is down
  • 2004/1/29 18:00

  • phlewis

  • Just popping in

  • Posts: 19

  • Since: 2003/6/16


I have the same problem.

Is there another headline module?

3
spiff
Re: Site won't load when news feed is down
  • 2004/8/17 16:36

  • spiff

  • Just popping in

  • Posts: 47

  • Since: 2003/4/16


This seems to have been an issue last night with one of our sites running 2.0.7.

It would be pretty easy to hack the headlines update script to first ping sites before attempting to load a feed to prevent having the server wait for a timeout.

In the file /modules/xoopsheadline/class/headlinerenderer.php, replacing this code (around line 60):
function updateCache()
{
  if (!
$fp fopen($this->_hl->getVar('headline_rssurl'), 'r')) {
    
$this->_setErrors('Could not open file: '.$this->_hl->getVar('headline_rssurl'));
    return 
false;
  }
  <
etc>

with the following (UNTESTED):
function pingDomain$url ) {
  
preg_match_all'/http://([w.]{2,})/i'$url$match );
  
$url $match[1][0];
  
exec"ping -n 4 $url"$list );
  foreach ( 
$list as $l ) {
    if ( 
preg_match'/unknown host/i'$l ) )
      return 
false;
    if ( 
preg_match'/100% packet loss/i'$l ) )
      return 
false;
  }
  return 
true;
}
function 
updateCache()
{
  
$url $this->_hl->getVar('headline_rssurl');
  if ( !
pingDomain$url ) ) {
    
$this->_setErrors('Could not access domain: '.$url);
    return 
false;
  }
  if (!
$fp fopen($url'r')) {
    
$this->_setErrors('Could not open file: '.$url);
    return 
false;
  }


Of course, the pingDomain() method could be refactored out as a general-purpose utility function, since it could be useful to other modules as well.

I think this would greatly speed up the headlines module on failing feeds, since the fopen() wouldn't have to wait for the timeout.

The above code is not a universal solution. The format of return results on the ping command could be extended to other systems than Windows/Linux if applicable. It also depends on the availability of shell commands in the running PHP version. I'm not aware of a built-in ping command in PHP.

Please comment.

Eric

[EDIT: modified some errors in code, added UNTESTED ]

4
Oldpueblo
Re: Site won't load when news feed is down
  • 2004/11/9 22:43

  • Oldpueblo

  • Just popping in

  • Posts: 21

  • Since: 2004/11/9


This might explain why my site has been unavailable for a good part of the day. I'm a total newb to XOOPS and CMS in general. I'd like to have about 5 live news feeds on my frontpage update hourly for not only myself but my friends. But after reading a bit I'm thinking maybe that can make it really slow? Or unavailable if one of them goes down (I think that happened today). Can anyone give some general guidelines for good Headline usage on the frontoage? Does the number of lines per feed make a difference in performance at all (5 feeds with 3 lines each, etc)?

Login

Who's Online

357 user(s) are online (308 user(s) are browsing Support Forums)


Members: 0


Guests: 357


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits