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.

My app is not connecting to my server.



  • I have an application which ought to be connected to a remote server, but the problem i am encountering is this. If i should test my html file on my browser, it will work fine, and i will be able to send and receive back my data. but, testing with monaca Localtoolkit or building its APK, it won’t connect to the net. I am using angularjs for this connection…



  • This is the appearance of my config file

    <?xml version="1.0" encoding="UTF-8"?>
    <widget xmlns="http://www.w3.org/ns/widgets" id="com.example.helloworld" version="1.0.0">
      <name>TheSlider</name>
      <description/>
      <author/>
      <content src="index.html"/>
      <allow-navigation href="*"/>
      <allow-intent href="itms:*"/>
      <allow-intent href="itms-apps:*"/>
      <preference name="loglevel" value="DEBUG"/>
      <preference name="AndroidLaunchMode" value="singleTop"/>
      <preference name="ErrorUrl" value=""/>
      <preference name="SplashScreen" value="screen"/>
      <preference name="AllowInlineMediaPlayback" value="false"/>
      <preference name="AutoHideSplashScreen" value="true"/>
      <preference name="BackupWebStorage" value="cloud"/>
      <preference name="EnableViewportScale" value="false"/>
      <preference name="FadeSplashScreen" value="true"/>
      <preference name="FadeSplashScreenDuration" value=".25"/>
      <preference name="KeyboardDisplayRequiresUserAction" value="true"/>
      <preference name="MediaPlaybackRequiresUserAction" value="false"/>
      <preference name="ShowSplashScreenSpinner" value="false"/>
      <preference name="SuppressesIncrementalRendering" value="false"/>
      <preference name="TopActivityIndicator" value="gray"/>
      <preference name="GapBetweenPages" value="0"/>
      <preference name="PageLength" value="0"/>
      <preference name="PaginationBreakingMode" value="page"/>
      <preference name="PaginationMode" value="unpaginated"/>
      <feature name="LocalStorage">
        <param name="ios-package" value="CDVLocalStorage"/>
      </feature>
      <preference name="UIWebViewDecelerationSpeed" value="normal"/>
      <preference name="monaca:targetFamilyiPhone" value="1"/>
      <preference name="monaca:targetFamilyiPad" value="1"/>
      <preference name="monaca:WebViewEngine" value="default"/>
      <access origin="*"/>
      <preference name="KeepRunning" value="true"/>
      <preference name="monaca:AndroidIsPackageNameSeparate" value="false"/>
      <preference name="DisallowOverscroll" value="true"/>
      <preference name="Orientation" value="default"/>
      <preference name="SplashScreenDelay" value="1000"/>
      <preference name="Fullscreen" value="false"/>
    </widget>
    
    


  • Maybe the CSP (Content Security Policy) not allow this action, check the CSP of your html page (on local the localhost is trusted) .

    this is sample 192.168.1.2 is the name of a server :

    <meta http-equiv="Content-Security-Policy" content="
          default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval' 'unsafe-inline' http://192.168.1.2;
          style-src 'self' 'unsafe-inline';
          font-src 'self';
          connect-src 'self' http://192.168.1.2:8080 http://192.168.1.2 ws://192.168.1.2;
          img-src 'self' data:"
        />
    

    You can generate one here : http://cspisawesome.com.



  • am i going to add this to the header of my html pages???
    cos, my previous thought is this…using the whitelist plugin in my cordova, i should be able to egt pass this Content Security Policy

    @Munsterlander suggested that cordova plugin could have been my problem…but, i am definitely lost in this

    NOTE: i do not have access to the database, i was only given a url with different op…to post my request.

    @Andi



  • Yes add the meta tag in your header (<head>…</head>).



  • @badlee

    thanks for that…and please, what if in a situation, i am only permitted to send my request into a URL…without having access to the server…how will i go about it pls



  • This 192.168.1.2 is always confusin’