NOAA RSS Advisory 2.0 PHP Script

yea, this is so nice I want to start using it as soon as we test it well. :slight_smile:

I think I got it now…

http://www.snoqualmieweather.com/wxtest.php

V2.00 02-Jun-2009 BETA .010

  • added a few minor formatting changes the the alert messages

Good work there mike. Playing around with it now.

Which formatting do you like better:

This?

Last updated: Tue, 02-Jun-2009 09:26pm PDT
Effective: Tue, 02-Jun-2009 08:44pm PDT
Expires: Tue, 02-Jun-2009 11:00pm PDT

(Cap Codes) Urgency: Expected, Severity:, Moderate, Certainty: Likely, Status: Actual, Type: Alert, Category: Met

Or this?

Last updated: Tue, 02-Jun-2009 09:26pm PDT
Effective: Tue, 02-Jun-2009 08:44pm PDT
Expires: Tue, 02-Jun-2009 11:00pm PDT

Urgency: Expected
Severity: Moderate
Certainty: Likely
Status: Actual
Type: Alert
Category: Met

My choice is the first one because it takes fewer lines.

Yea i would have to agree the first one is better.
Got it up and running now on one of the main pages.

Agree… The first one.

Seems like the beta isn’t picking up our Local Heat Advisory. Not unless I missed a setup somewhere.

http://www.weather.gov/alerts/wa.html#WAZ505.SEWNPWSEW.100500

http://www.snoqualmieweather.com/wxtest.php

This is from my View Source…



<div id="main-copy">
<div class="advisoryBoxnoactive"><!-- wxtest.php - V2.00 02-Jun-2009 BETA .009 -->
<!-- getting new file from http://www.weather.gov/alerts-beta/wwaatmget.php?x=WAZ505 -->
<!-- CURL GET /alerts-beta/wwaatmget.php?x=WAZ505 HTTP/1.0 Host: www.weather.gov -->
<!-- CURL Network error: Operation timed out with 0 out of -1 bytes received -->
<!-- CURL Network error: Operation timed out with 0 out of -1 bytes received -->
<!-- Time to fetch: 24.154 sec -->
<!-- HTML fetch length = 0 ; Cache not saved. -->
<!-- headers n/a -->
There are no active watches, warnings or advisories for zone WAZ505.</div>
    <p> </p>
</div><!-- end main-copy -->


But it also looks like the NWS could be having some problems, cause the original advisory isnt working either at the present time.

Advisory Information Unavailable, error reading RSS Data saved from the NOAA advisories server.

The NWS is having some problems today. This is a good opportunity for me to work on error handling.

I see a problem with what you posted because in this scenario it should not print “There are no active watches, warnings or advisories for zone WAZ505.” It should print: “Advisory Information Unavailable, error fetching data from the NOAA advisories server.”

<!-- rss-advisory-2009.php - V2.00 02-Jun-2009 BETA .011 -->
<!-- getting new file from http://www.weather.gov/alerts-beta/wwaatmget.php?x=WAZ021 -->
<!-- CURL GET /alerts-beta/wwaatmget.php?x=WAZ021 HTTP/1.0 Host: www.weather.gov -->
<!-- Time to fetch: 20.689 sec -->
<!-- HTML fetch length = 52 ; Cache not saved. -->
<!-- Headers received: n/a -->
<!-- HTML received: Can't connect to MySQL server on 'mysql-cluster' (4) -->
<p>Advisory Information Unavailable, error fetching data from the <a href="http://www.weather.gov/alerts-beta/wwaatmget.php?x=WAZ021">NOAA advisories server.</a></p>

<!-- Zone='WAZ021' -->

I almost have it all fixed on my development server …new beta coming soon.

It did change on its own now to say…

“Advisory Information Unavailable, error fetching data from the NOAA advisories server.”

So thats a good sign.

V2.00 03-Jun-2009 BETA .011

lots of code rearrangement - improvements

  • fixed error handling for when the NOAA servers are having problems. Soft failures are printed in html comments as usual. (hopefully I did not break stuff for when NOAA is working again)
  • fixed potential problem if NOAA servers fail while fetching fullMessages, it will fall back to $fullMessagesMode off so that it can still show the summary alert message instead of an error. (assuming you still have a valid summary alert message available.) Soft failures are printed in html comments as usual.
  • changes to simplify graceful_error function.

Here is an example of what you get if NOAA server is having a Mysql problem:

Your visitor sees:
“Advisory Information Unavailable, error fetching or reading data from the NOAA advisories server.”
Many times when an error like this happens there is a long delay while fetching, so the error is cached for your set cache interval.
Your visitor can refresh and there is no delay.

View the source of the HTML:

<div class="advisoryBoxnoactive"><!-- advisories.php - V2.00 03-Jun-2009 BETA .011 -->
<!-- using cached version from rss-advisory-2009-WAZ021.txt - age=23 secs. Next fetch in 577 secs. -->
<!-- Warning: cache file size = 90 is too small.. XML data not found. -->
<!-- Cache file HTML contents: Lost connection to MySQL server at 'reading initial communication packet', system error: 0 -->
<p>Advisory Information Unavailable, error fetching or reading data from the <a href="http://www.weather.gov/alerts-beta/wwaatmget.php?x=WAZ021">NOAA advisories server.</a></p>
<!-- zone=WAZ021 -->
</div>

Any time you want to troubleshoot a problem, view the source of the HTML

Edit: beta 11 has a problem, stay tuned for beta 12…

V2.00 03-Jun-2009 BETA .012

Fixed all known problems, all prior versions should be discarded. :lol:

Hi Mike getting this error on the newest beta:
Warning: fread() [function.fread]: Length parameter must be greater than 0 in /home3/johnsto1/public_html/weather/rss-advisory-2009.php on line 326

Advisory Information Unavailable, error fetching or reading data from the NOAA advisories server.

I was getting that too every now and then. But i think it has more to do with the NWS having problems, rather than the script itself.

Seen that if i delete the txt file that it creates, then it works but doing a refresh on the page the error hits every time.

Like right now. My page just had it again. When I refresh it goes away. Then If i go back in 5 mins, it could be there again. The NWS has been having problems since early this morning, and still are. i really think “could be wrong” that its on there end thats causing the issues were seeing.

It is related to the server problems NOAA is having. I have already fixed that error on my next version to be released in a few minutes.

V2.00 03-Jun-2009 BETA .013

fixed all reported errors, all prior versions should be discarded. :lol:

Ok working good here, as in that error no longer there. Now have to wait for NOAA to fix there issue.

The latest works good Mike. My Advisory Is showing now that NOAA is back up.

http://www.snoqualmieweather.com/wxtest.php