Author Topic: Saratoga NOAA IPv6 Issues  (Read 278 times)

0 Members and 1 Guest are viewing this topic.

Offline WoodburyMan

  • Member
  • *
  • Posts: 10
    • Southington Weather
Saratoga NOAA IPv6 Issues
« on: September 17, 2024, 12:17:50 PM »
Greetings!
The webhost i use for Saratoga templates is IPv6 enabled (DreamHost). As such, Curl when fetching Forecast data from api.weather.gov is defaulting to IPv6. However, NOAA/Akamai ALWAYS have issues with IPv6 on their site, with incorrect AAAA records or firewall issues it seems. This sometimes is sporadic, and recently for the last week or so has not worked at all and I've unable to get forecast data. Logs show TCP_Denied in this case.
Code: [Select]
---------------------------------------------
2024-09-17T15:56:29+00:00 (local: Tue, 17 Sep 2024 11:56:29 -0400) - advforecast2.php (JSON) - V5.19 - 27-Dec-2022
Fetch fail
<!-- curl fetching 'https://api.weather.gov/points/41.5993,-72.8862' -->
<!-- HTTP stats:  RC=403 dest=2600:1409:9800:688::116 port=443 (from sce=2607:f298:6:a014::afe:273b)
      Times: dns=0.354 conn=0.358 pxfer=0.366 get=0.012 total=0.378 secs -->
<!-- headers returned:
HTTP/2 403
server: AkamaiGHost
mime-version: 1.0
content-type: text/html
content-length: 408
cache-control: max-age=0
expires: Tue, 17 Sep 2024 15:56:29 GMT
date: Tue, 17 Sep 2024 15:56:29 GMT
x-cache: TCP_DENIED from a23-53-123-12.deploy.akamaitechnologies.com (AkamaiGHost/11.6.3-e8c44af76fbf2725bc66e35706b8e3bb) (-)
x-edge-request-id: 7c6ccbb
vary: Accept,Feature-Flags,Accept-Language
strict-transport-security: max-age=31536000 ; includeSubDomains ; preload
x-akamai-request-id: 7c6ccbb
 -->

I modified advforecast2.php around line 1328 and added the last line here
Code: [Select]
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $numberOfSeconds); //  connection timeout
    curl_setopt($ch, CURLOPT_TIMEOUT, $numberOfSeconds); //  data timeout
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the data transfer
    curl_setopt($ch, CURLOPT_NOBODY, false); // set nobody
    curl_setopt($ch, CURLOPT_HEADER, true); // include header information
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // Set Curl to use IPV4 - CUSTOM

This immediately fixes my issue. If any others are having problems on IPv6 enabled hosts with NOAA's servers, I suggest using this. Figure I would post those with the same issues.
There are other functions too where this can copy/paste into like in  get-metar-conditions-inc.php and nws-alerts.php as well


It might be worth while to add this in, as IPv6 with NOAA has been an issue for me for 2+ years. Might be safe to force IPv4 and in a year or two test and see if its better.
Southington, CT https://www.southingtonweather.com
GW2000 + CumulusMX (WS90[Wind+Solar],WH57[Lightning],WH32[OutdoorTemp],2xWH31[Indoor Temp],WN51[Soil],WH55[Leak])

Woodbury, CT https://www.woodburyweather.com
GW1100 +CumuluxMX

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 9559
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: Saratoga NOAA IPv6 Issues
« Reply #1 on: September 17, 2024, 03:44:04 PM »
It's an issue with Akamai/IPV6/firewall for the NWS sites.

Good discussion here https://github.com/weather-gov/api/discussions/763

It was about 403 returns (firewall issues), but generally about Akamai's handling of IPV6 for NWS.. they're trying to get it fixed, but your tweak to the curl calls of
Quote
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); // Set Curl to use IPV4 - CUSTOM
is a good one for hosts that are set up with IPV6 defaults.

Thanks for sharing 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

Offline dwhitemv

  • KORJUNCT3
  • Member
  • *
  • Posts: 40
    • My PWS on Weather Underground
Re: Saratoga NOAA IPv6 Issues
« Reply #2 on: September 23, 2024, 05:12:56 PM »
A fix for the improper blocking was pushed on September 19, 2024. Try accessing the API over IPv6 again and post to the GitHub thread if you are still being blocked. Include the contents of the x-edge-request-id header so NWS can look into it.

 

anything