API Overage

Posted on
Thu Sep 13, 2018 5:45 am
DaveL17 offline
User avatar
Posts: 4245
Joined: Aug 20, 2013

API Overage

Just a head's up that I awoke today to find my FUWU plugin displaying the following message every minute:
Code: Select all
   Fantastic Weather Error         Unable to decode data. (Line 843) No JSON object could be decoded
   Fantastic Weather Warning       Unable to reach Dark Sky. Sleeping until next scheduled poll.
   Fantastic Weather               Fantastic Weather cannot determine age of data. Skipping until next scheduled poll.

When I manually loaded the Dark Sky URL into a browser, it reported "daily usage limit exceeded".

I'm just starting to look into what caused the problem. The plugin had been working stably for many weeks before now, but clearly there's something awry. One problem is that the error found a way to circumvent the "next scheduled poll" trap as I have my plugin set to refresh every 15 minutes and the error caused the plugin to retry every minute. I'll post more information when I figure out what's going on. You may want to keep an eye on the plugin and disable it if you see the above error in the log or if your API usage is extra high.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Sep 13, 2018 7:57 am
lanbrown offline
Posts: 665
Joined: Sep 26, 2017

Re: API Overage

I would suggest that people take their poll interval and divide that into 1440 and then set the limit in the plugin to something slightly higher. This way if this does happen, you can temporarily increase the limit. That is how I have mine setup and when this occurs, I at least have a reserve of API calls to use.

Posted on
Thu Sep 13, 2018 8:18 am
DaveL17 offline
User avatar
Posts: 4245
Joined: Aug 20, 2013

Re: API Overage

Thanks for the advice. The daily limit for the free API is 1,000 calls--mine would have used 1,440 if it hadn't maxed out the limit. Users can set the limit (as you suggested) through the Dark Sky account settings. My install *should have been* using 96 calls per day at 15 minute intervals. The plugin is supposed to keep the calls below the number set in the plugin preferences dialog, but clearly that wasn't happening in this case. I still need to figure out why.

That said, I've been able to do some preliminary research into the conditions at the time this error happened and--given the conditions that caused it to happen--it's pretty unlikely that anyone will see the error. If you do, please let me know. I won't be able to do any testing until my API count is reset at midnight UTC.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Sep 13, 2018 7:58 pm
DaveL17 offline
User avatar
Posts: 4245
Joined: Aug 20, 2013

Re: API Overage

I've done a lot more research into this error and I'm pretty confident that no one else will see it, so there's most likely nothing to worry about. It was caused by a confluence of conditions that included non-public code--therefore, it shouldn't even happen with public releases of the plugin.

I do believe that setting the daily API call limit to something lower than the max number of calls per day is good advice. It appears that the plugin's API call limiter was working after all, I just had mine precisely (and stupidly) set to the max daily limit. Lesson learned.

Even though this will likely not resurface, the exercise was useful. As a result of this excitement, I will make a point of adding more robust error trapping to try to eliminate the possibility of an error causing the once-per-minute API call error state.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Posted on
Thu Sep 13, 2018 8:15 pm
lanbrown offline
Posts: 665
Joined: Sep 26, 2017

Re: API Overage

I have mine set for 300. So even if it went through the 300 for some reason, I would still have plenty left after I took care of whatever was causing it to run amuck.
If you go with a 5 minute polling interval that is 12 per hour and then multiply by 24 hours and you get 288. So even if I drop the interval down to 5 minutes, the current limit would allow for it.

Just tossing an idea out there. What if you set the limit per hour? If the limit per hour is reached, the plugin could reload itself?

Posted on
Fri Sep 14, 2018 5:36 am
DaveL17 offline
User avatar
Posts: 4245
Joined: Aug 20, 2013

Re: API Overage

I appreciate the thought. In the case that caused the error, several steps needed to be taken to recover from it [to reiterate, this is not an error that anyone should come across] that couldn't be easily automated.

I came here to drink milk and kick ass....and I've just finished my milk.

[My Plugins] - [My Forums]

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 1 guest