android userservice login/createUser WebException

0 votes
Hi, APP42 Support Team:

    I create an "ACL ==  true" app.

    And I get a exceptin: "WebException" when i revoke login/createuser at the android device(why???)

    And my android device have good internet connection.

    But at the pc, it works ok.

    How to solve it?

    thank you!
asked Jul 8, 2014 in App42 Cloud API-BaaS by riovoxtools (45 points)
Can you provide some more details like in which platform you are working on and logs when you are calling the App42 SDK ? Also, if you can share your manifest file of android project that would be helpful?
This webexcetion is  In android platform,  and I use sumsung device, when I call login function,  it display webexception. I will provide you logs and manifest file tomorrow.  But the app42 SDK works ok in ios platform.
Hi, I use unity to develop in android platform,
function:
try
{
   mUserService.Authenticate(userName, password);
}
catch(Exception ex)
{
  // display webexception
}
try
{
   mUserService.CreateUser(userName, password, email);
}
catch(Exception ex)
{
   // display webexception
}

my exception logs:
System.Net.WebException: Error writing request: The authentication or decryption has failed.
at System.Net.WebConnectionStream.WriteHeaders () [0x00000] in <filename unknown>:0
at System.Net.WebConnectionStream.SetHeaders (System.Byte[] buffer) [0x00000] in <filename unknown>:0
at System.Net.HttpWebRequest.SendRequestHeaders (Boolean propagate_error) [0x00000] in <filename unknown>:0

And my androidManifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.unity3d.player" android:installLocation="preferExternal" android:versionCode="1" android:versionName="1.0">
  <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
  <application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
    <activity android:name="com.unity3d.player.UnityPlayerProxyActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    </activity>
    <activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <meta-data android:name="android.app.lib_name" android:value="unity" />
      <meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
    </activity>
    <activity android:name="com.unity3d.player.VideoPlayer" android:label="@string/app_name" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
    </activity>
    <!-- ACTIVITIES -->
    <!-- META-DATA -->
  </application>
  <!-- PERMISSIONS -->
</manifest>

Thanks!
Can you please use the async methods in your app and let me know if this error will occur again ?
but i use the same way at the ios platform, is works ok.

And all my code is use syn methods, It will be a big project if I change all my syn methods to async methods.
why it have exception when  i use async methods ?

1 Answer

0 votes
 
Best answer

Hi Riovox,

In sync method, we use .net library for making an https connection with App42. For a security reason, mono does not allow to use https connection in Unity App. This problem occurs when you try to access the https connection using sync method.

Please use the code snippet to resolve the connection problem while you are making a connection with App42 in your Android app:

using System.Net;

 

#if UNITY_EDITOR

public static bool Validator (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate, System.Security.Cryptography.X509Certificates.X509Chain chain, System.Net.Security.SslPolicyErrors sslPolicyErrors)

         {return true;}

#endif

void Start ()

{

#if UNITY_EDITOR

   ServicePointManager.ServerCertificateValidationCallback = Validator;

#endif

ServiceAPI serviceAPI = new ServiceAPI("KEY1","KEY2");

}

 

Let me know if it helps.

Thanks.

 

answered Jul 10, 2014 by hs00105 (517 points) 1 flag
selected Aug 19, 2014 by riovoxtools
OK, I use "UNITY_ANDROID"  instead of "UNITY_EDITOR",
Now, it works ok.
Thank you! ! !! !! !! ! ! !!
Hi, now I am facing "WebException: Error: NameResolutionFailure", is it same with  you?
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...