Welcome to the Cumulus Support forum.

Latest Cumulus MX release 3.6.12 (build 3088) - 10 July 2020 (please see important announcement regarding releases since 3.5.0)
Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of the NOAA report and Snow Index drop-down menus to 2030)

Use this link to Download the Software (Cumulus MX / Cumulus 1 and other related items). Software

Parser error: Unexpected Error < in JSON at position 0

Discussion of Mark Crossley's HTML5/Javascript gauges

Moderator: mcrossley

Post Reply
Vegit8
Posts: 76
Joined: Fri 27 Sep 2013 2:11 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 10
Location: Somerset
Contact:

Parser error: Unexpected Error < in JSON at position 0

Post by Vegit8 »

For years I have been running various weather stations into Cumulus and then to my site www.geoffwebber.co.uk/weather.
A short while ago I began to get errors (after a number of iterations) displayed in the 'forecast' bar on the gauges page thus "'Text file download corrupted - retrying'."
Reload the page and the problem went away.

Thinking this might be an issue due to using 'old' technology, I bit the bullet and upgraded to Cumulus MX and took the opportunity to update the Steel Series guages at the same time.

Everything works fine after the usual bit of fiddling...

But I am still getting the same problem.
The forecast displays (and updates) as does all the other gauges on www.geoffwebber.co.uk/weather/gauges-ss.htm, then after a while I now get the message
'Parser error: Syntax Error: unexpected token < in JSON at position 0'

Having started my computing life with typing in code from a magazine and all the debigging that went with it, I half understand the problem.

However - what confuses me is why the display works fine for a while - then errors, then works fine again after a page referesh.
Also how do I debug JSON (which I admit confuses me) to find the rogue <?

This problem is the same on all platforms / browser types..

Any ideas anyone??

Cheers
Last edited by Vegit8 on Tue 25 Feb 2020 1:52 pm, edited 1 time in total.

User avatar
HansR
Posts: 1115
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: Davis Vantage Pro 2+
Operating System: Raspbian GNU/Linux 10 (Buster)
Location: Wagenborgen (NL)
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by HansR »

If i load your page (in FF) it runs perfectly well until it times out for the real-time updates.
No error message seen here.
https://meteo-wagenborgen.nl / Cumulus 3.6.8 (build: 3084)
Davis Vantage Pro 2+ / Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian Linux 10 (buster) / 4.19.118-v7+ armv7l
Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:31:43 UTC 2020)

User avatar
HansR
Posts: 1115
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: Davis Vantage Pro 2+
Operating System: Raspbian GNU/Linux 10 (Buster)
Location: Wagenborgen (NL)
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by HansR »

Second attempt: "unexpected character at line 1 column 1 of JSON data."
Nr of seconds to update is adding iso counting down.

I also notice a parameter in the URL which I can't explain: http://www.geoffwebber.co.uk/weather/ga ... MCL=uc5BDt (and which doubles a second time). Don't have the time to examine everything but did you change things to the page or the menu?
https://meteo-wagenborgen.nl / Cumulus 3.6.8 (build: 3084)
Davis Vantage Pro 2+ / Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian Linux 10 (buster) / 4.19.118-v7+ armv7l
Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:31:43 UTC 2020)

User avatar
saratogaWX
Posts: 1035
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: Parser error: Unexpedted Error < in JSON at position 0

Post by saratogaWX »

The issue may be caused by a missing script:

/weather/scripts/windrose.js is not on your server, so it returns a 404-Not Found HTML page which has a < in it which breaks the scripting (it was expecting JavaScript, not HTML).

Make sure the windrose.js is on the site or change the page to not load the missing script.

User avatar
mcrossley
Posts: 6630
Joined: Thu 07 Jan 2010 9:44 pm
Weather Station: Davis VP2
Operating System: Buster Lite rPi
Location: Wilmslow, Cheshire, UK
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by mcrossley »

I *think* your website may have been hacked.

After a while instead of the JSON response it sends a HTML page containing a JavaScript function that has its code encoded to prevent scanning of it. I have only seen code like that before when it has been malicious. It could be innocent, but...

Vegit8
Posts: 76
Joined: Fri 27 Sep 2013 2:11 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 10
Location: Somerset
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by Vegit8 »

Hi All

Thank you for your replies.
I seem to have fixed it.
I changed the forecast data from Cumulus to the Davis version - in gauges.js

SaratogaWX - cant find windrose.js anywhere in the CumulusMX install, and my windrose gauge seems to work ok in anycase.

Have checked my website, nothing there seems to indicate it may have been hacked.
The only pages I host are the weather related ones and that whole directory was replaced when I upgraded to MX, although the problem persisted.

I use a (very) strong password for FTP and only use SFTP for connections so I think the likelihood of being compromised is very low.

Cheers everyone.

User avatar
saratogaWX
Posts: 1035
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: Parser error: Unexpedted Error < in JSON at position 0

Post by saratogaWX »

In your cumulus\web\gauges-ssT.htm , just remove the line

Code: Select all

<script src="scripts/windrose.js"></script>
and that should fix the issue with the unused (and missing) script.

I checked out the odd encoded JavaScript returned by the page, and it resulted in JavaScript code being executed of

Code: Select all

window.open(Lu+"?LMCL=Iwr5Ym"+vs,"_self")
so, not malicious -- just reopening the same page with a GET argument of ?LMCL=lw5Ym... Not harmful, just strange. After a cursory search, it appears it may be 123-reg hostings built-in anti DDOS efforts as other sites hosted on 123-reg had wondered about it too. Certainly an odd way to handle a 404-Not Found error.
Last edited by saratogaWX on Mon 24 Feb 2020 4:57 pm, edited 1 time in total.

Vegit8
Posts: 76
Joined: Fri 27 Sep 2013 2:11 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 10
Location: Somerset
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by Vegit8 »

Excellent - thank you

User avatar
HansR
Posts: 1115
Joined: Sat 20 Oct 2012 6:53 am
Weather Station: Davis Vantage Pro 2+
Operating System: Raspbian GNU/Linux 10 (Buster)
Location: Wagenborgen (NL)
Contact:

Re: Parser error: Unexpedted Error < in JSON at position 0

Post by HansR »

Ah, that explains the weird argument I saw :)
https://meteo-wagenborgen.nl / Cumulus 3.6.8 (build: 3084)
Davis Vantage Pro 2+ / Raspberry Pi 3 Model B Plus Rev 1.3
Raspbian Linux 10 (buster) / 4.19.118-v7+ armv7l
Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:31:43 UTC 2020)

Vegit8
Posts: 76
Joined: Fri 27 Sep 2013 2:11 pm
Weather Station: Davis Vantage Pro2
Operating System: Win 10
Location: Somerset
Contact:

Re: Parser error: Unexpected Error < in JSON at position 0

Post by Vegit8 »

Update..
After a suggestion in this thread that the problem may lie with my hosting provider I did a bit of investigation, and found other users of different websites having the same problem.
I contacted 123 Reg support, who straight away acknowledged the problem.
As suggested it was a measure they take to deal with DOS attacks.
I was given an alternate IP address on a server which does not have whatever measures they employ on the normal one.
Result... problem gone

So my issue seems to be specific to my hosting provider.

Post Reply