tags:

views:

199

answers:

2

I have a script that reads RSS feeds using fopen & fgets.

When trying to the feed at: http://rss.fok.nl/feeds/nieuws my script hangs until the max_timeout of the PHP is reached.

The thing is:

  • it worked perfectly (on the same url) until today.
  • it still works on my development mac MAMP server.
  • it doesn't work on the production WAMP server (php 5.2.8)

I tried fread with no success.

any ideas?

A: 

Perhaps try to debug your connection using wireshark (Ethereal). This should give you the reason. Perhaps the webserver is blocking your requests because of the user-agent.

Can you download the file manually on the Windows machine?

theomega
manually it works fine
Omer
+1  A: 

Well, it's more of a workaround than an answer, but I had to resort to it. I used the following to switch over to curl, using this function:

function curl_get_file_contents($URL)
{
    $c = curl_init();
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($c, CURLOPT_URL, $URL);
    $contents = curl_exec($c);
    curl_close($c);

    if ($contents) return $contents;
        else return FALSE;
}

I found it here: http://il.php.net/manual/en/function.file-get-contents.php

btw, in case anyone wants to dig deeper, according to other reports of fgets hanging, it seems it has something to do with the 'feof' or lack thereof...

Omer