Welcome to the Cumulus Support forum.

Latest Cumulus MX release v3.0.0 build 3050 - 1 May 2019.
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014

See the Wiki for downloading either version.

USNO-sunmoon error messages

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
aznetcowboy
Posts: 292
Joined: Fri 04 Jan 2013 6:03 pm
Weather Station: Davis 6153 Vantage Pro2
Operating System: Windows 10 Home 64-bit
Location: Tucson, AZ
Contact:

USNO-sunmoon error messages

Post by aznetcowboy » Fri 23 Nov 2018 5:15 pm

All of a sudden I am getting this error messages today:

Warning: Invalid argument supplied for foreach() in /home/gydfbaoo/public_html/get-USNO-sunmoon.php on line 360

Warning: Invalid argument supplied for foreach() in /home/gydfbaoo/public_html/get-USNO-sunmoon.php on line 371


What is causing this and what do I do to correct it? I have changed nothing in this script or any script for at least a couple months and then it was just for upgrades/updates.
Tom Wills
Kingston Knolls Terrace, Tucson, AZ

El Gheko Neighborhood Weather Station: http://www.elgheko.us
El Gheko Neighborhood Association: http://na.elgheko.us

Image

User avatar
saratogaWX
Posts: 971
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: USNO-sunmoon error messages

Post by saratogaWX » Fri 23 Nov 2018 5:55 pm

It looks like the USNO has switched to HTTPS today.

Code: Select all

<!-- curl fetching 'http://api.usno.navy.mil/rstt/oneday?date=11/23/2018&coords=32.2217,-110.84444&tz=-7' -->
<!-- HTTP stats:  RC=301 dest=199.211.133.93 port=80 (from sce=23.254.240.227)
      Times: dns=0.000 conn=0.053 pxfer=0.053 get=0.059 total=0.112 secs -->
<!-- headers returned:
HTTP/1.1 301 Moved Permanently
Date: Fri, 23 Nov 2018 17:51:59 GMT
Server: Apache
Location: https://api.usno.navy.mil/rstt/oneday?date=11/23/2018&coords=32.2217,-110.84444&tz=-7
Content-Length: 301
Content-Type: text/html; charset=iso-8859-1
 -->
Change get-USNO-sunmoon.php from

Code: Select all

  $USNOUrl = "http://api.usno.navy.mil/rstt/oneday?date=$lclToday&coords=$myLat,$myLong&tz=$myTZOffset";
to

Code: Select all

  $USNOUrl = "https://api.usno.navy.mil/rstt/oneday?date=$lclToday&coords=$myLat,$myLong&tz=$myTZOffset";

User avatar
saratogaWX
Posts: 971
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: USNO-sunmoon error messages

Post by saratogaWX » Fri 23 Nov 2018 6:12 pm

I've released V3.02 with the https fix .. available now from the update tool page 23-Nov-2018, Base=*, Plugin-*

User avatar
aznetcowboy
Posts: 292
Joined: Fri 04 Jan 2013 6:03 pm
Weather Station: Davis 6153 Vantage Pro2
Operating System: Windows 10 Home 64-bit
Location: Tucson, AZ
Contact:

Re: USNO-sunmoon error messages

Post by aznetcowboy » Thu 20 Dec 2018 4:06 pm

saratogaWX wrote:
Fri 23 Nov 2018 6:12 pm
by saratogaWX » Fri Nov 23, 2018 11:12 am
I've released V3.02 with the https fix .. available now from the update tool page 23-Nov-2018, Base=*, Plugin-*
I did the update as you suggested and it has been working okay ever since... that is until today. This morning I am getting the error as follows:
Warning: Invalid argument supplied for foreach() in /home/gydfbaoo/public_html/get-USNO-sunmoon.php on line 361

Warning: Invalid argument supplied for foreach() in /home/gydfbaoo/public_html/get-USNO-sunmoon.php on line 372


This is confusing. Do I need to go after another update? :?
Tom Wills
Kingston Knolls Terrace, Tucson, AZ

El Gheko Neighborhood Weather Station: http://www.elgheko.us
El Gheko Neighborhood Association: http://na.elgheko.us

Image

User avatar
saratogaWX
Posts: 971
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: USNO-sunmoon error messages

Post by saratogaWX » Thu 20 Dec 2018 4:56 pm

No, no need to update the script. Your site is reporting
<!-- get-USNO-sunmoon.php - Version 3.02 - 23-Nov-2018 -->
<!-- refetch seconds=1 -->
<!-- loading ./cache/USNO-moondata.txt from https://api.usno.navy.mil/rstt/oneday?d ... 4444&tz=-7 -->
<!-- curl fetching 'https://api.usno.navy.mil/rstt/oneday?d ... 4444&tz=-7' -->
<!-- curl Error: Connection timed out after 30001 milliseconds -->
<!-- HTTP stats: RC=0 dest= port=0 (from sce=)
Times: dns=0.003 conn=0.000 pxfer=0.000 get=30.002 total=30.002 secs -->
<!-- headers returned:

-->
<!-- Error loading from USNO API, cache not saved -->
<!-- loading finished. -->
<!-- processing JSON entries for Moon data -->
<!-- json_decode returns - Syntax error, malformed JSON -->
With the USNO having issues, just add (or change) your Settings.php to have

Code: Select all

$SITE['useUSNO'] = false;
to switch to the built-in calculations instead of using the USNO.

User avatar
ConligWX
Posts: 749
Joined: Mon 19 May 2014 10:45 pm
Weather Station: Davis VPro2 Plus +DFARS
Operating System: MeteoBridge Nano SD
Location: Bangor, NI
Contact:

Re: USNO-sunmoon error messages

Post by ConligWX » Fri 21 Dec 2018 4:24 pm

just reported this over on your forums Ken.

https://www.wxforum.net/index.php?topic ... #msg366210
Regards Simon

https://www.conligwx.org - @conligwx
Davis Vantage Pro2 Plus - Meteobrige Nano SD + Saratoga Templates

User avatar
aznetcowboy
Posts: 292
Joined: Fri 04 Jan 2013 6:03 pm
Weather Station: Davis 6153 Vantage Pro2
Operating System: Windows 10 Home 64-bit
Location: Tucson, AZ
Contact:

Re: USNO-sunmoon error messages

Post by aznetcowboy » Sat 22 Dec 2018 6:51 pm

ConligWX wrote:
Fri 21 Dec 2018 4:24 pm
by ConligWX » Fri Dec 21, 2018 9:24 am
just reported this over on your forums Ken.

https://www.wxforum.net/index.php?topic ... #msg366210
While this sounds good (maybe even great), where does the code

} else {
$Debug.= "<!-- Error loading from USNO API, cache not saved -->\n";
return ("");
}


get placed :roll: ?
Tom Wills
Kingston Knolls Terrace, Tucson, AZ

El Gheko Neighborhood Weather Station: http://www.elgheko.us
El Gheko Neighborhood Association: http://na.elgheko.us

Image

BCJKiwi
Posts: 879
Joined: Mon 09 Jul 2012 8:40 pm
Weather Station: Davis VP2 Cabled with Solar
Operating System: Windows 10 Pro
Location: Auckland, New Zealand
Contact:

Re: USNO-sunmoon error messages

Post by BCJKiwi » Sat 22 Dec 2018 8:18 pm

PLEASE DISREGARD THIS SUGGESTION.
There are a couple of other changes required elsewhere to properly implement this modification.
BCJKiwi

Ken has given you the clue.
Provided you are using ver 3.02 of the script as recommended, you can switch between using USNO or built-in code. The built-in code does not provide all the variables that USNO does but sufficient for the standard website templates.

Instead of adding
return ("");

you can instead add
$useUSNO = false; // USNO fetch/process failed, set switch to false to use built-in calculations

As to where to do this, search for
$Debug.= "<!-- Error loading from USNO API
which is at line 164 in the original ver 3.02 get_USNO-sunmoon.php file

INSERT the new code on a new line immediately after the original line 164

Using this method, the normal operation will be to use USNO but if there is a problem accessing that data, then the built in calculations will be used automatically. Of course you could just switch to he built-in calculations permanently as suggested by Ken.
Last edited by BCJKiwi on Sun 23 Dec 2018 7:56 pm, edited 1 time in total.

User avatar
saratogaWX
Posts: 971
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: USNO-sunmoon error messages

Post by saratogaWX » Sat 22 Dec 2018 9:15 pm

I suggest it is better long-term to leave the basic script unmodified (so you can just replace it when it has a new release in the future) and to instead use the Settings.php entry to switch to internal calculations. If you are not into code compare old vs. new and refitting your mods, the Settings.php method is the way to have the least issues when updates are needed.

Mark14
Posts: 57
Joined: Thu 23 Aug 2012 8:53 pm
Weather Station: WH 2080
Operating System: Windows 7
Location: Konin, Poland

Re: USNO-sunmoon error messages

Post by Mark14 » Fri 21 Jun 2019 10:03 am

I have similar problem even after updating the script: http://serwer1823145.home.pl/check-fetch-times.php

For a week following message has popped up:
Warning: Invalid argument supplied for foreach() in /get-USNO-sunmoon.php on line 361

Warning: Invalid argument supplied for foreach() in /get-USNO-sunmoon.php on line 372
How to fix it?

User avatar
saratogaWX
Posts: 971
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: USNO-sunmoon error messages

Post by saratogaWX » Fri 21 Jun 2019 2:30 pm

The api.usno.navy.mil site seems to be having issues for a couple of days.

Add

Code: Select all

$SITE['useUSNO'] = false;
to your Settings.php to force using the internal moon calculations instead of the USNO for moon data.

Post Reply