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.
---------------------------------------------
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
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.