Search code examples
zend-frameworkrss-readeratom-feedzend-feed

Zend_Feed_Reader exception: Read timed out after 10 seconds


I am using Zend_Feed_Reader to read feeds but I have a problem. At some feeds, I get this exception: Read timed out after 10 seconds and I want to reduce that time.

So in the case Zend_Feed_Reader can't read that feed in 4 seconds threw this exception. I don't want him to try to read for 10 seconds, if he can't read it in 4 seconds give it up.

Is this possible?


Solution

  • Like many ZF components, Zend_Feed_Reader uses Zend_Http_Client for its communication with external services, and you can provide it a pre-configured instance of this class for custom functionality (such as using a HTTP proxy, custom useragent, or in your case, timeout):

    $client = new Zend_Http_Client(null, array(
        'timeout' => 4
    ));
    Zend_Feed_Reader::setHttpClient($client);
    

    then just use the component as you were before:

    $feed = Zend_Feed_Reader::import('http://example.com/some-feed.rss');