hsarkanen / JollaOpas

Jolla Opas
GNU General Public License v3.0
4 stars 4 forks source link

JSON.parse errors in reittiopas.js #30

Closed tpikonen closed 2 years ago

tpikonen commented 4 years ago

Reverse geocoding, itinerary finding etc. do not work with HSL reittiopas data. I'm getting this kind of log messages:

[W] unknown:90 - file:///usr/share/harbour-jollaopas/qml/js/reittiopas.js:90: JSON.parse: Parse error
[W] unknown:57 - file:///usr/share/harbour-jollaopas/qml/js/reittiopas.js:57: JSON.parse: Parse error
[W] unknown:151 - file:///usr/share/harbour-jollaopas/qml/js/reittiopas.js:151: JSON.parse: Parse error
Tegu commented 3 years ago

I was getting the same error but now I finally noticed that switching from HTTPS to HTTP seems to fix the problem. Of course, it is not an ideal solution. I guess it has something to with TLS versions or parameters since fetching the same URL with curl on the device works just fine. I have not investigated further.

A temporary fix below:

diff --git a/qml/js/reittiopas.js b/qml/js/reittiopas.js
index f311d5b..fea933a 100644
--- a/qml/js/reittiopas.js
+++ b/qml/js/reittiopas.js
@@ -33,7 +33,7 @@

 var API = {}
 API['digitransitgeocoding'] = {}
-API['digitransitgeocoding'].URL = 'https://api.digitransit.fi/'
+API['digitransitgeocoding'].URL = 'http://api.digitransit.fi/'

 /****************************************************************************************************/
 /*                     address to location                                                          */
tpikonen commented 3 years ago

Thanks, I can confirm that using http in stead of https makes the parse errors go away.

hsarkanen commented 2 years ago

I tested and checked this one. It seems that plain http is not supported anymore by Digitransit API. I hope that Sailfish OS SSL certificates are updated by Jolla so this workaround is unnecessary.