News:

  • November 06, 2025, 03:10:37 PM

Login with username, password and session length

Author Topic: Weather.gov access denied  (Read 4185 times)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Weather.gov access denied
« on: November 10, 2022, 04:52:58 PM »
I have a need to collect local realtime weather data to the BRX.

In a PC-based HMI with an HTTP Get function I can poll www.weather.gov/xml/current_obs/XXXX.xml", where XXXX is the four letter code for the location.    This returns XML that I can parse for whatever variables I want.    Temp, RH, etc.

In a browser, strangely, that same request works but instead of displaying the XML I get a formatted web page.

From the BRX, I get "Access denied".   Can't figure out what I need to do.
« Last Edit: November 10, 2022, 05:10:32 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3769
    • Host Engineering
Re: Weather.gov access denied
« Reply #1 on: November 10, 2022, 05:18:47 PM »
Here's our local example:
https://w1.weather.gov/xml/current_obs/KGCY.xml

Your browser is using a CSS style sheet to render the data.  Check out http://csszengarden.com/ for ways to render the same static web page content but formatted in a gazillion different ways using different CSS style sheets.

See if you can get to any http file from your PLC - something you know (should) work.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #2 on: November 10, 2022, 05:56:43 PM »
I'm running it in the SIM on my laptop.   Don't think there's an issue at the PC access level since I can access the page via both HMI software and browser.

This is the XML for KCGY:

Code: [Select]
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet href="latest_ob.xsl" type="text/xsl"?>
<current_observation version="1.0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://www.weather.gov/view/current_observation.xsd">
<credit>NOAA's National Weather Service</credit>
<credit_URL>https://weather.gov/</credit_URL>
<image>
<url>https://weather.gov/images/xml_logo.gif</url>
<title>NOAA's National Weather Service</title>
<link>https://www.weather.gov</link>
</image>
<suggested_pickup>15 minutes after the hour</suggested_pickup>
<suggested_pickup_period>60</suggested_pickup_period>
<location>Greeneville-Greene County Municipal Airport, TN</location>
<station_id>KGCY</station_id>
<latitude>36.19601</latitude>
<longitude>-82.81099</longitude>
<observation_time>Last Updated on Nov 10 2022, 5:35 pm EST</observation_time>
        <observation_time_rfc822>Thu, 10 Nov 2022 17:35:00 -0500</observation_time_rfc822>
<weather>Overcast</weather>
<temperature_string>66.0 F (19.0 C)</temperature_string>
<temp_f>66.0</temp_f>
<temp_c>19.0</temp_c>
<relative_humidity>64</relative_humidity>
<wind_string>Northeast at 9.2 MPH (8 KT)</wind_string>
<wind_dir>Northeast</wind_dir>
<wind_degrees>50</wind_degrees>
<wind_mph>9.2</wind_mph>
<wind_kt>8</wind_kt>
<pressure_in>30.04</pressure_in>
<dewpoint_string>53.6 F (12.0 C)</dewpoint_string>
<dewpoint_f>53.6</dewpoint_f>
<dewpoint_c>12.0</dewpoint_c>
<visibility_mi>10.00</visibility_mi>
  <icon_url_base>https://forecast.weather.gov/images/wtf/small/</icon_url_base>
<two_day_history_url>https://www.weather.gov/data/obhistory/KGCY.html</two_day_history_url>
<icon_url_name>ovc.png</icon_url_name>
<ob_url>https://www.weather.gov/data/METAR/KGCY.1.txt</ob_url>
<disclaimer_url>https://www.weather.gov/disclaimer.html</disclaimer_url>
<copyright_url>https://www.weather.gov/disclaimer.html</copyright_url>
<privacy_policy_url>https://www.weather.gov/notice.html</privacy_policy_url>
</current_observation>
« Last Edit: November 10, 2022, 05:59:47 PM by Controls Guy »
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #3 on: November 10, 2022, 05:57:41 PM »
I CAN get forum.hosteng.com/index.php
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3769
    • Host Engineering
Re: Weather.gov access denied
« Reply #4 on: November 11, 2022, 08:55:58 AM »
The website uses https, not http, so Port 80 may not work on that website.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #5 on: November 11, 2022, 09:22:56 AM »
I think I tried both 80 and 443.   SSL checked and unchecked. Maybe I'll Wireshark the HMI to see what it's doing.  It has an option for secure that I didn't need to use.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3769
    • Host Engineering
Re: Weather.gov access denied
« Reply #6 on: November 11, 2022, 10:05:20 AM »
Show us the status using SSL.  Port 80 can be causing the 403 error you are seeing:
403.4 SSL required. Use HTTPS instead of HTTP to access the page.

Get past that and show the ladder status for that failure (response status code in D2)

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #7 on: November 11, 2022, 10:05:56 AM »
Will do, thanks!
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3769
    • Host Engineering
Re: Weather.gov access denied
« Reply #8 on: November 11, 2022, 10:08:32 AM »
Also, all the text in your buffer.  Memory View screen shot would be good in ASCII format.  It can show a ton of bytes (literally) compared to Data View.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #9 on: November 11, 2022, 10:47:55 AM »
Yeah, that's what I've been using.  Does work well.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3769
    • Host Engineering
Re: Weather.gov access denied
« Reply #10 on: November 11, 2022, 10:55:42 AM »
Yeah, that's what I've been using.  Does work well.

Memory View (a bunch of 'em) has become a fan favorite around these parts.  When you have multi-monitors, it's even better!!

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #11 on: November 11, 2022, 12:07:13 PM »
OK same on SSL/443

Gonna Wireshark the HMI
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6130
  • Yes Pinky, Do-more will control the world!
Re: Weather.gov access denied
« Reply #12 on: November 11, 2022, 12:36:40 PM »
You need to add a "User-Agent: <something useful here>" request header. I just stuck "User-Agent: BRX" in and it appeared to work. See https://stackoverflow.com/questions/32641072/current-observation-feed-from-weather-gov-forbidden-403
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #13 on: November 11, 2022, 12:55:47 PM »
Yup!   That did the trick.   Thanks!
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3601
  • Darth Ladder
Re: Weather.gov access denied
« Reply #14 on: November 11, 2022, 03:38:44 PM »
Dangit, worked once and is now giving a 301 error.  "Permanently moved". I noticed this in the DAQ Factory Wireshark as well, but didnt seem to fail the request.   I think I have a PCAP.  If so, I'll send it.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.