apiCache.txt keeps becoming corrupted

Post Reply
milesb
Observer
Observer
Posts: 49
Joined: Tue Mar 26, 2019 10:38 pm
Location: Asheville, NC
Station model: Davis Vantage Pro2
Software: Weather Display
Contact:

apiCache.txt keeps becoming corrupted

Post by milesb » Thu Jan 09, 2025 4:57 pm

Having an issue where the database stops updating because the template/cache/apiCache.txt file becomes corrupted.

This has been an issue in the past, but occurred very infrequently. The fix is to simply delete the file and the database again starts updating. This would usually happen no more than 2 to 3 times a year. The gaps this causes in the database, is easily filled in by exporting that month's data from WeatherDisplay and importing it from within Meteotemplate.

Now all of a sudden it is happening almost daily. There have been no changes on my end, i.e. WD settings, and none I'm aware of on the hosting side.

I'm kinda at a loss as to how to resolve this issue.

jps
Observer
Observer
Posts: 16
Joined: Tue Dec 21, 2021 8:53 am
Station model: Davis pro 2

Re: apiCache.txt keeps becoming corrupted

Post by jps » Fri Jan 10, 2025 9:16 am

hello Miles

same behavior here too,
frequency is roughly 1 time per month for me

cheers

davidefa
Expert
Expert
Posts: 888
Joined: Tue Jan 12, 2021 8:03 am
Location: Italy
Station model: WH2650
Software: WH2650 (direct upload)
Contact:

Re: apiCache.txt keeps becoming corrupted

Post by davidefa » Sat Jan 11, 2025 11:45 am

It would be useful if you could provide a copy of a faulty apiCache.txt ( if I understand correctly the file is not updated any more when this happen ) so I can test it.
If you are on stock meteotemplate 19.0 api.php script you can try one of the updated scripts attached ( I use ver 3.6a ), simply rename the version you choose to api.php and overwrite the original script in your root meteotemplate directory ( make a backup copy of the original script ).
If it solves your issue you are ok, if not it has a few setting to help understand what's going wrong:
1) near line 60 you can set

Code: Select all

$logGetPost = 1;
to enable logging of the requests received in file cache /apiReqLog.txt ( to help understand which one is causing the problem )
2) these scripts also generate an cache/apiErrorLog.txt log with all errors occurring in api.php, which would go otherwise unnoticed

P.S.
Only forgot to add that the fault is surely on the WD part ( meteotemplate can never be blamed ; - )
Attachments
api_3.4_3.6a.zip
(38.02 KiB) Downloaded 434 times
Image

milesb
Observer
Observer
Posts: 49
Joined: Tue Mar 26, 2019 10:38 pm
Location: Asheville, NC
Station model: Davis Vantage Pro2
Software: Weather Display
Contact:

Re: apiCache.txt keeps becoming corrupted

Post by milesb » Sun Jan 12, 2025 8:57 pm

It appears that the frequency updates are sent to template/api.php will cause the template/cache/apiCache.txt file to become corrupted.

I am running WeatherDisplay on my end, and had the update frequency set to 15 seconds. I noted that the apiCache.txt file was updating every 5 seconds on my site. I confirmed that WD was still set to update every 15 seconds, and even changed it 30 seconds. The updates were still happening every 5 seconds.

I restarted the computer running WD (Windows 10}, and it is now updating every 30 seconds, the setting in WD, and the problem seems resolved. I did update WD about 3 weeks prior to this problem starting. I had also restarted the computer running WD several times since as I updated several things unrelated to WD or updating my site, including replacing the UPS.

I am going to leave the update frequency at 30 seconds for now to see if there are any more occurrences.

milesb
Observer
Observer
Posts: 49
Joined: Tue Mar 26, 2019 10:38 pm
Location: Asheville, NC
Station model: Davis Vantage Pro2
Software: Weather Display
Contact:

Re: apiCache.txt keeps becoming corrupted

Post by milesb » Sun Jan 19, 2025 5:03 pm

Changing the frequency for updating api.php has solved another issue. I had WD configured to send updates every 15 seconds for quite a while, and I had a problem with precipitation being carried over to the next day. It was easy to resolve by editing the 00:00:00 entry in the database, to set the rain total to 0.00.

It appears that changing the update frequency to every 30 seconds has also eliminated this problem.

Post Reply