[nh_api_twitteruser / api collection] unpredictable error

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
louisk
Forum Members
Forum Members
Posts: 89
Joined: Wed May 30, 2007 7:40 pm

[nh_api_twitteruser / api collection] unpredictable error

Post by louisk »

The nh_api_twitteruser add-ons/plugin/tag is working fine most of the time, but once in the couple refreshes I get this error above the twitter output:

Warning: file_get_contents(http://twitter.com/statuses/user_timeli ... t=5&page=1) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 503 Service Temporarily Unavailable in /home/user/domains/domain.com/public_html/plugins/function.nh_essentials.php on line 46

When I refresh the page, it disappears again.

What could be the problem?
nhaack

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by nhaack »

Hi there,

I'm the author of that plug-in. It is a problem with the twitter API and the plug-in not being able to handle these problems at the moment.

"503 Service Temporarily Unavailable" indicates the problem. With more and more applications accessing the twitter API in general, they do have serious load issues by times. You can try to increase your caching time to bypass the problem for now. It will reduce the calls to the API and as such reduce the probability of hitting the error.

Sorry, no real fix for this at the moment.

Best
Nils
louisk
Forum Members
Forum Members
Posts: 89
Joined: Wed May 30, 2007 7:40 pm

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by louisk »

Okay, I understand, but is it possible to not have the error shown... Can I hide it some way?
nhaack

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by nhaack »

Hi Luisk,

I'm working on a new version featuring a few improvements (including the problem you have mentioned. However, it'll most likely still take some weeks till a solution.

At the moment I can only ask you to be patient :(

You could try to add

Code: Select all


error_reporting(0);

to the plugin, right after

Code: Select all


function smarty_cms_function_nh_api_twitteruser($params, &$smarty)

in the twitter user feed api plug-in and right after

Code: Select all


function get_external_xml($cache_location,$external_xml,$cache_ttl,$natural_encoding)

in the api essentials file.

That should surpress any error messages. See if that works and let me know if that fixes your problem.

Best
Nils
tristan
Dev Team Member
Dev Team Member
Posts: 375
Joined: Tue May 02, 2006 10:58 am
Location: The Netherlands

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by tristan »

Hi there,

lately with all the Twitter downtime, we've been getting a similar error:

Warning: file_get_contents(http://twitter.com/statuses/user_timeli ... t=3&page=1) [function.file-get-contents]: failed to open stream: Connection timed out in /home/user/domains/domain.com/public_html/plugins/function.nh_essentials.php on line 46

Since the plugin waits for a reply from Twitter the complete website has to wait on every page for the timeout from Twitter before it serves up any page. So just suppressing the error doesn't solve it. Any clues?
nhaack

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by nhaack »

It'a a shame I know :(. I didn't yet publish the newer version.The problem is the following: one could theoretically bypass the waiting for the server reply, but this would detach output from requesting.

Currently, the plugin tries to request the twitter api data once the cache is outdated. The problem is, with the request, it's overwriting the cache with an answer that doesn't contain any messages in case of a twitter problem.

The interims solution is to check the file content before storing. This is what a version I have in use does. This works much better. Though still, you would have to wait for the timeout answer. I also have experimented with another approach that just request the twitter content from a local database table that is updated by an external script via CRON jobs.

This ensures a great performance but makes the plugin much more complex. Currently a lot of things a re changing in my life and I just don't find the time to update it. I will update it sooner or later, but it will take a while until I have changed city and everything.

Unfortunately, I can not provide an immediate solution to the problem. However, I'm now aware, that there is some urgency and I'll tyr to deal with it as soon possible.

Sorry for any inconvenience.

Best
Nils
tristan
Dev Team Member
Dev Team Member
Posts: 375
Joined: Tue May 02, 2006 10:58 am
Location: The Netherlands

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by tristan »

Just sent you a direct message, very interested in the interim version!
nhaack

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by nhaack »

Here is an interims solution. You need to update the file "function.nh_essentials.php" with the attached file (remove *.txt from file name) :)

The change will do the following:

It will check if the first 5 characters of the answer are "<?xml" - if so, the answer will most likely be ok and the cache will be updated. If the answer does noch begin with this string, it will skip the update, touch the file to prolong caching and serve the cached file.

This will solve the problem of twitter downtimes resulting in a broken answer being cached. However, it is not a very good error handling. Because the plug-in does not know per se that the API has a problem. One would have to examine the header for example.

Additionally there is nothing such as a global wait value (e.g. don't query the API for the next 15 minutes). So if the API is down, your visitors will experience a slow site, because the plug in is waiting for the twitter API to respond. To prevent this from happening to every visitor, the cached file will be touched, so the timestamp is never and your system won't request anything from the twitter api for the next "YOUR_SET_CACHE_TIME" seconds.

Theoretically, you only have to overwrite this file in your cmsms and be fine. Please note: These are untested modifications. Use at own risk and don't test on production system ;)

Let me know if that solved your problem.

Best
Nils
Attachments

[The extension txt has been deactivated and can no longer be displayed.]

tristan
Dev Team Member
Dev Team Member
Posts: 375
Joined: Tue May 02, 2006 10:58 am
Location: The Netherlands

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by tristan »

Awesome that was exactly the change I hinted at with that cache time wait on error, perfect! Now we just have to wait untill Twitter is down again to test this thing. Thanks for the fast response by the way!
deactivated010521

Re: [nh_api_twitteruser / api collection] unpredictable erro

Post by deactivated010521 »

----------
Last edited by deactivated010521 on Tue Mar 12, 2013 3:29 pm, edited 1 time in total.
nhaack

Re: [nh_api_twitteruser / api collection] unpredictable error

Post by nhaack »

Hi arnoud,

thanks for posting your approach :)

Best
Nils
Post Reply

Return to “Modules/Add-Ons”