Author Topic: Almanac data not displaying on Saratoga Templates  (Read 2208 times)

0 Members and 1 Guest are viewing this topic.

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Almanac data not displaying on Saratoga Templates
« on: April 29, 2016, 03:16:20 PM »
Having run my own basic html weather website for some years, I have decided to experiment with the Saratoga Templates. I use MeteoBridge and think I have everything set up and uploading correctly. I have installed the files in a subdirectory in order to keep my root clean, but have left all the relative paths unchanged.

My experimental site is here: - http://www.wessexweather.net/saratoga/wxindex.php

Everything seems to be working except the Almanac panel on the front page, and the Sun/Moon Almanac which does not display the correct sun and moon data. The errors returned at the top of these pages are: -

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

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

I have ensured the cache directory permissions are set a 776.

I am sure there is a very simple explanation, and I see these errors have been reported before, but having checked all the solutions and spent hours pouring over the settings files, I must have overlooked something.

Any help would be greatly appreciated.
Cheers,

Simon (WessexWeather)


Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: Almanac data not displaying on Saratoga Templates
« Reply #1 on: April 29, 2016, 03:46:11 PM »
This is the one I use, might work for you.

Ian
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #2 on: April 29, 2016, 04:00:24 PM »
Thanks Ian, looks great on your site, but it doesn't work for me unfortunately.
Cheers,

Simon (WessexWeather)


Offline Ian.

  • Forecaster
  • *****
  • Posts: 460
    • Chatteris Weather
Re: Almanac data not displaying on Saratoga Templates
« Reply #3 on: April 29, 2016, 04:07:53 PM »
How about this one.
CWOP - DW3371
PWS - ICAMBRID16
https://www.chatteris.biz

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #4 on: April 29, 2016, 04:35:22 PM »
To be honest I don't think the astronomy php file is the problem, rather it's a setting in the script somewhere that's affecting how the data is pulled into the sunmoon php file and cache. Possibly something to do with the fact that I have installed the templates in a subdirectory.
Cheers,

Simon (WessexWeather)


Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Almanac data not displaying on Saratoga Templates
« Reply #5 on: April 30, 2016, 04:40:25 AM »
To be honest I don't think the astronomy php file is the problem, rather it's a setting in the script somewhere that's affecting how the data is pulled into the sunmoon php file and cache. Possibly something to do with the fact that I have installed the templates in a subdirectory.
The script get-USNO-sunmoon.php is unable to get its data from http://api.usno.navy.mil/
This is the debug information from the script:
Code: [Select]
<!-- get-USNO-sunmoon.php - Version 2.04 - 11-Nov-2015 -->
<!-- refetch seconds=1 -->
<!-- loading ./cache/USNO-moondata.txt from http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1 -->
<!-- GET /rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1 HTTP/1.1
      Host: api.usno.navy.mil  Port: 80 IP=199.211.133.93-->
<!-- Network error: Connection timed out (110) -->
<!-- HTTP stats:  dns=0.025 conn=5.005 put=n/a get( blocks)=n/a close=n/a total=5.030 secs -->
<!-- fetch function elapsed= 5 secs. -->
<!-- loading finished. -->
<!-- processing JSON entries for Moon data -->
<!-- json_decode returns  - No errors -->
<!-- note: 'fracillum' not in JSON, no 'illumination' is available. -->
<!-- USNOdata
Array
(
)
 -->
So there is no data returned at all.
This can have a lot of reasons:  Invalid DNS data, block by your provider, block by USNO when data is loaded to frequently.

I attach a smal test-program.  Unzip and put it on your site and run it.
http://www.wessexweather.net/test_usno.php

This test program will retrieve the data from USNO twice.
1. In an iframe in your browser. This should work ALWAYS, if it fails then probably the USNO server is down
2. On your webserver using CURL.  It will print all debug info to check what type of error we have.

To obscure the script for others you can give it another name. But please send a PM with the new name so I can check the output.

Wim





Offline gwwilk

  • Southeast Lincoln Weather
  • Forecaster
  • *****
  • Posts: 2578
    • SouthEast Lincoln, NE Weather
Re: Almanac data not displaying on Saratoga Templates
« Reply #6 on: April 30, 2016, 12:14:34 PM »
To be honest I don't think the astronomy php file is the problem, rather it's a setting in the script somewhere that's affecting how the data is pulled into the sunmoon php file and cache. Possibly something to do with the fact that I have installed the templates in a subdirectory.
The script get-USNO-sunmoon.php is unable to get its data from http://api.usno.navy.mil/
This is the debug information from the script:
Code: [Select]
<!-- get-USNO-sunmoon.php - Version 2.04 - 11-Nov-2015 -->
<!-- refetch seconds=1 -->
<!-- loading ./cache/USNO-moondata.txt from http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1 -->
<!-- GET /rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1 HTTP/1.1
      Host: api.usno.navy.mil  Port: 80 IP=199.211.133.93-->
<!-- Network error: Connection timed out (110) -->
<!-- HTTP stats:  dns=0.025 conn=5.005 put=n/a get( blocks)=n/a close=n/a total=5.030 secs -->
<!-- fetch function elapsed= 5 secs. -->
<!-- loading finished. -->
<!-- processing JSON entries for Moon data -->
<!-- json_decode returns  - No errors -->
<!-- note: 'fracillum' not in JSON, no 'illumination' is available. -->
<!-- USNOdata
Array
(
)
 -->
So there is no data returned at all.
This can have a lot of reasons:  Invalid DNS data, block by your provider, block by USNO when data is loaded to frequently.

I attach a smal test-program.  Unzip and put it on your site and run it.
http://www.wessexweather.net/test_usno.php

This test program will retrieve the data from USNO twice.
1. In an iframe in your browser. This should work ALWAYS, if it fails then probably the USNO server is down
2. On your webserver using CURL.  It will print all debug info to check what type of error we have.

To obscure the script for others you can give it another name. But please send a PM with the new name so I can check the output.

Wim
What you really need to know about the USNO site is that any repeat requests from the same IP address within around 15 minutes will be blocked by them.  That's why I went a different route in my sunposa.php by using Solaris' moonphase.php instead of relying on the USNO site.  It took several months to iron out problems with the moon phases using 'moonphase.php', but I think it's close enough for everyday use now.

You can find the code in this thread.
« Last Edit: April 30, 2016, 12:29:44 PM by gwwilk »
Regards, Jerry Wilkins
gwwilk@gmail.com

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #7 on: April 30, 2016, 02:10:22 PM »
Quote
This test program will retrieve the data from USNO twice.
1. In an iframe in your browser. This should work ALWAYS, if it fails then probably the USNO server is down
2. On your webserver using CURL.  It will print all debug info to check what type of error we have.

To obscure the script for others you can give it another name. But please send a PM with the new name so I can check the output.

Wim

Thanks for your help Wim. I have uploaded the file to http://www.wessexweather.net/saratoga/test_usno.php. Let me know when you've checked the output and I will delete it.

Best regards,

Simon
« Last Edit: May 01, 2016, 05:29:52 PM by WessexWeather »
Cheers,

Simon (WessexWeather)


Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #8 on: April 30, 2016, 02:12:46 PM »
Quote
What you really need to know about the USNO site is that any repeat requests from the same IP address within around 15 minutes will be blocked by them.  That's why I went a different route in my sunposa.php by using Solaris' moonphase.php instead of relying on the USNO site.  It took several months to iron out problems with the moon phases using 'moonphase.php', but I think it's close enough for everyday use now.

You can find the code in this thread.

Thanks gwwilk, I will check this out if I have no success with the standard script.
Cheers,

Simon (WessexWeather)


Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Almanac data not displaying on Saratoga Templates
« Reply #9 on: April 30, 2016, 02:44:30 PM »
Quote
This test program will retrieve the data from USNO twice.
1. In an iframe in your browser. This should work ALWAYS, if it fails then probably the USNO server is down
2. On your webserver using CURL.  It will print all debug info to check what type of error we have.

To obscure the script for others you can give it another name. But please send a PM with the new name so I can check the output.

Wim
Thanks for your help Wim. I have uploaded the file to http://www.wessxweather.net/saratoga/test_unso.php. Let me know when you've checked the output and I will delete it.

Best regards,

Simon
When you run it you will see that no data at all is returned. So you should ask the support desk of your provider if they are blocking you or that USNO is doing it.

They can run the script and run a traceroute  to check who is doing this.
One can inspect the script by adding ?sce=view
http://www.wessexweather.net/saratoga/test_usno.php?sce=view

Wim


Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #10 on: April 30, 2016, 03:53:06 PM »
Wim,

I have been touch with my host, and they are not blocking USNO, nor is my IP blocked.

This is the link the script is calling, which looks correct to me : -

http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1

Is the date format correct? The coords certainly are, although there is no minus sign before the longitude...

They have also tried curl: -

# curl -I 'http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1' curl: (7) couldn't connect to host curl: (7) couldn't connect to host [1]- Exit 7 curl http://api.usno.navy.mil/rstt/oneday?date=04/30/2016 [2]+ Done coords=50.79359436,2.07669806

The tech support also tried connecting from their local machine, which failed as well, so they are assuming all IPs are blocked or the link is simply offline.

Could this be correct? I'm sure I've seen the data showing correctly on other sites.
Cheers,

Simon (WessexWeather)


Offline wvdkuil

  • Wim van der kuil
  • Forecaster
  • *****
  • Posts: 1986
    • My PWS at Leuven Belgium Europe
Re: Almanac data not displaying on Saratoga Templates
« Reply #11 on: April 30, 2016, 04:16:05 PM »
Wim,

I have been touch with my host, and they are not blocking USNO, nor is my IP blocked.

This is the link the script is calling, which looks correct to me : -

http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1

Is the date format correct?
Yes, it is month,day,year  US format
Quote
The coords certainly are, although there is no minus sign before the longitude...
Does not really matter now, as moon data can be retrieved for any place on earth.
And for almost any date now, past or future.
This is their website access   http://aa.usno.navy.mil/data/docs/RS_OneDay.php    for which we are using the api.
Quote
They have also tried curl: -

# curl -I 'http://api.usno.navy.mil/rstt/oneday?date=04/30/2016&coords=50.79359436,2.07669806&tz=1' curl: (7) couldn't connect to host curl: (7) couldn't connect to host [1]- Exit 7 curl http://api.usno.navy.mil/rstt/oneday?date=04/30/2016 [2]+ Done coords=50.79359436,2.07669806

The tech support also tried connecting from their local machine, which failed as well, so they are assuming all IPs are blocked or the link is simply offline.Could this be correct?
The link is online as you and me and thousands other can access the USNO  server. It seems there IP-range is blocked as they can not access it from within there offices. 

A simple test:  they should use a smart-phone to access the link to the USNO site using a 4G network. It should work as long as it is not their 4G network.
I assume they can not even access the USNO  website http://aa.usno.navy.mil/data/docs/RS_OneDay.php from their servers either.
Quote
I'm sure I've seen the data showing correctly on other sites.
The URL should always return data. That is why there is an iframe at the top op the test script.This data should be in the iframe:
Code: [Select]
{
"error":false,
"apiversion":"1.2.0",
"year":2016,
"month":4,
"day":30,
"dayofweek":"Saturday",
"datechanged":false,
"lon":2.076698,
"lat":50.793594,
"tz":1,

"sundata":[
            {"phen":"BC", "time":"04:50"},
            {"phen":"R", "time":"05:27"},
            {"phen":"U", "time":"12:49"},
            {"phen":"S", "time":"20:12"},
            {"phen":"EC", "time":"20:49"}],

"moondata":[
            {"phen":"R", "time":"02:16"},
            {"phen":"U", "time":"07:10"},
            {"phen":"S", "time":"12:11"}],

"closestphase":{"phase":"Last Quarter","date":"April 30, 2016","time":"04:29"}
}
You should ask them to contact USNO and explain the situation and what they should do to  lift the block.

Wim
« Last Edit: April 30, 2016, 04:20:32 PM by wvdkuil »

Offline WessexWeather

  • Senior Member
  • **
  • Posts: 83
    • WessexWeather
Re: Almanac data not displaying on Saratoga Templates
« Reply #12 on: April 30, 2016, 05:33:10 PM »
Thanks Wim,

I asked them to check and they have indeed suggested their IP addresses might be blocked, although they were also unable to gain access via mobile 3G. Whilst their servers are based in the UK, I have discovered that they operate from Ukraine, which surprised me. They have said they will try and contact USNO but weren't very optimistic, and nor am I!

I am beginning to wonder if I should change host...

Regards, Simon
Cheers,

Simon (WessexWeather)