0 Replies Latest reply on Feb 5, 2018 10:29 AM by EncloCreation

    Phonegap problems with socket.io

    EncloCreation

      Im having some trouble implementing socket.io on my phonegap app. Ive tried the following solutions:

       

      -installing cordova-plugin-whitelist

      -installing cordova-plugin-websocket

      -setting access origin in the xml file

      -Implementing content-secutriy-policy across all my html files

       

      My config.xml file:

      <?xml version='1.0' encoding='utf-8'?>

      <widget id="com.noname.app" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:gap="http://phonegap.com/ns/1.0">

          <name>noname</name>

          <description>

              A blank PhoneGap app.

          </description>

          <author email="support@phonegap.com" href="http://phonegap.com">

              PhoneGap Team

          </author>

          <content src="index.html" />

          <access origin="http://192.168.1.112:80" />

          <gap:plugin name="cordova-plugin-whitelist" source="npm"/>

          <gap:plugin name="cordova-plugin-websocket" source="npm"/>

      </widget>

      The project is running on 192.168.1.112:80

       

      Content Security Policy meta tags (Implemented on all the html files on my app)

      <meta http-equiv="Content-Security-Policy" content="default-src *; script-src * 'unsafe-inline'; object-src *; img-src *; media-src *; frame-src *; font-src *; connect-src * ">

      <meta http-equiv="X-Content-Security-Policy" content="default-src *; script-src * 'unsafe-inline'; object-src *; img-src *; media-src *; frame-src *; font-src *; connect-src*">

      <meta http-equiv="X-WebKit-CSP" content="default-src *; script-src * 'unsafe-inline'; object-src *; img-src *; media-src *; frame-src *; font-src *; connect-src *">

       

      The project works fine on the ripple emulator on my desktop, the plain site also works well.

      In fact it even works perfectly when using the phone gap app and connecting to the ipadress the project

      is running on on the phone gap desktop app. Its just when I convert it to apk and try to run it independently

      the web sockets simply dont work, has anyone had this problem before and if so how did you fix it. Thanks