Page 1 of 1

Parser error: Unexpected Error < in JSON at position 0

Posted: Fri 21 Feb 2020 3:37 pm
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

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

Posted: Sat 22 Feb 2020 8:14 am
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.

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

Posted: Sat 22 Feb 2020 8:34 am
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?

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

Posted: Sat 22 Feb 2020 5:00 pm
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.

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

Posted: Sat 22 Feb 2020 5:38 pm
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...

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

Posted: Sun 23 Feb 2020 3:59 pm
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.

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

Posted: Mon 24 Feb 2020 1:16 am
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.

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

Posted: Mon 24 Feb 2020 9:06 am
by Vegit8
Excellent - thank you

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

Posted: Mon 24 Feb 2020 4:32 pm
by HansR
Ah, that explains the weird argument I saw :)

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

Posted: Fri 13 Mar 2020 8:50 am
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.