Author Topic: Problems with api.weather.gov today...  (Read 1334 times)

0 Members and 1 Guest are viewing this topic.

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Problems with api.weather.gov today...
« on: July 12, 2017, 01:46:39 PM »
The advforecast2.php V5 script is getting connect-time-out errors to api.weather.gov so point forecasts (and Zone forecasts) may be unavailable for a while.  It's also likely that your forecast shows as yesterday's forecast.

When they resolve the api.weather.gov problem, the forecast should return to normal.

Nothing to see here.. please move along :)
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline Forever

  • Senior Contributor
  • ****
  • Posts: 211
Re: Problems with api.weather.gov today...
« Reply #1 on: July 12, 2017, 01:58:39 PM »
Thanks for the information Ken.
Is this what is causing my index page to load slowly today?

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problems with api.weather.gov today...
« Reply #2 on: July 12, 2017, 02:33:32 PM »
Likely, yes...  The script detects that the JSON cache is 'stale' and tries to reload it.
Quote
<!-- curl fetching 'https://api.weather.gov/points/37.2639,-122.022/forecast' -->
<!-- curl Error: Operation timed out after 6000 milliseconds with 0 bytes received -->
<!-- HTTP stats:  RC=0 dest=23.197.96.136 port=443 (from sce=192.168.1.104)
      Times: dns=0.172 conn=0.203 pxfer=0.234 get=5.141 total=5.375 secs -->
and times-out in the process.  That adds an additional 5+ seconds to the page load time.
Since the first fetch fails with no data, a second fetch for the Zone data is tried
Quote
<!-- curl fetching 'https://api.weather.gov/alerts?active=1&zone=CAZ513' -->
<!-- curl Error: Operation timed out after 6016 milliseconds with 0 bytes received -->
<!-- HTTP stats:  RC=0 dest=23.197.96.136 port=443 (from sce=192.168.1.104)
      Times: dns=0.000 conn=0.016 pxfer=0.047 get=5.156 total=5.203 secs -->
so another 5+ seconds elapses.
Total load time of 10 to 12 seconds is added to the page load time.
Both api.weather.gov and api-v1.weather.gov point to an akamai server (same IP) and preview-api.weather.gov is having the same connection time-out issue.  Something must be really screwed up at the api servers...

For those unable/unwilling to wait for resolution by the NWS, you can go back to the V4 script (assuming you have NOT converted your URLs to the new format).   Here's a copy of that script if you need it.
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Online Jasiu

  • Forecaster
  • *****
  • Posts: 951
    • LexMAWeather
Re: Problems with api.weather.gov today...
« Reply #3 on: July 17, 2017, 04:58:07 PM »
While all of that was going on, on my site I hacked in a way to call the advforecast script to force it to use the cache info, if there, no matter how old, and that's how I now call it from the home page. I have a cron job that does a force-fetch of the forecast to update the cache every 15 minutes, so it just doesn't make sense for every home page load to bother with the reload (and it certainly helps with the load time if the NWS isn't responding).

https://lexmaweather.info
On Mastodon: @LexMAWeather@toot.community

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9297
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Problems with api.weather.gov today...
« Reply #4 on: July 17, 2017, 07:00:39 PM »
The default cache lifetime was only 600 seconds (10 minutes) in the script.  Keep in mind that a ?force=1 will *try* the point forecast, and then put the Zone forecast in the cache if the point forecast isn't available.  So your use of cron just offloads a possible network issue with reading api.weather.gov from a page load on your site (which is not a bad thing, but is a somewhat unusual issue).
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP