Notice: The Monaca & Onsen UI Community Forum is shutting down.
For Onsen UI bug reports, feature requests and questions, please use the Onsen UI GitHub issues page. For help with Monaca, please contact Monaca Support Team.
Thank you to all our community for your contributions to the forum. We look forward to hearing from you in the new communication channels.
jsonp error acccessing LAN resource
-
Good Morning,
I’m an italian teacher building an educational app for my students.
I’m quite new here and I’ve tried the following:
config.xml: row <access origin="*" /> (manually added)
index.html:-
<meta http-equiv=“Content-Security-Policy” content=“default-src * data:; style-src * ‘unsafe-inline’; script-src * ‘unsafe-inline’ ‘unsafe-eval’; connect-src *”> (manually added)
-
and:
$.ajax({ url: "http://192.168.178.107:5000", jsonp: "jsonpcallback", dataType: "jsonp", type: "get", data: { prodotti: JSON.stringify(prodotti) }, success: function(data){ console.log(data.result); }, error: function(data){ var debug = document.querySelector("#debug").innerHTML = JSON.stringify(data); } })
cordova-plugin-whitelist: enabled
I would access LAN server resource http://192.168.178.107:5000. I have no problem using my PC browser, but I always receive the following in the a <div id = “debug”></div> once I try APK generated with Monaca.io:
{"readyState":4, "status": 404; "statusText": "error"}
I think the problem is on app side because I cannot see any request from my smartphone using WireShark.
I’m using pro-plan (for this month). What can I do?
Best Regards,
Stefano
-
-
Is your device running Android 9? HTTP communication is prohibited on Android 9 so you will need to use HTTPS. Even if you’re not running Android 9, it is worth changing your server HTTPS and trying again.
-
@emccorson said in jsonp error acccessing LAN resource:
Is your device running Android 9? HTTP communication is prohibited on Android 9 so you will need to use HTTPS
Thank you for your reply!
I’ve converted my HTTP server in HTTPS. I’m using Flask and it tells from debug console:- Running on https://0.0.0.0:5000/ (Press CTRL+C to quit)
I’m monitoring my LAN using WireShark but nothing seems to start from my smartphone. Instead I can see all packets generated from another application (I’m using TCP/UDP test tool).
I can also say that using “Custom Build Debugger” it works correctly. How can I create an operating APK with jsonp without using Custom Build Debugger?