AJAX Post to PlayFab fails on Android apk

0 favourites
From the Asset Store
We present to you “Post Apocalyptic Trailer” – our newest hard hitting, bass rumbling designed movie trailer collection.
  • Hello community!

    I have this issue with AJAX plugin: when I send a request to PlayFab via HTTP POST from my computer everything works fine but when I try to do the same on Android with the deployed APK the request fails and it is not logged on PlayFab platform like it cannot reach their server.

    Do you have some suggestions on the possibile reason for this?

    Thank you in advance

  • I had the same issue -- I think it might be playfab having issues...

  • Hmm dont't think is a PlayFab issue. I tried with another http listener and I don't see the request from my game when I am on Android and I see it when I am on PC

  • In general cross-domain requests have to be whitelisted by the remote server (sending the Access-Control-Allow-Origin: * header), must be secure (HTTPS), and mobile apps generally have to have any domains they communicate with specified in their configuration otherwise they are blocked by default.

  • Thank you for the response. How can I do it? I mean, I have already tried to put in the whitelist the playfab URL when a export my game APK from Construct. Am I missing something?

  • Hi, PlayFab currently has no issue with Android and iOS, neither does AJAX to PlayFab.

    Although, I'm slightly bit familiar with your current situation, had that same issue before (click here for the reference), not so long ago.

    It usually happens with this issue:

    1. Error 503, connection error.

    You can confirm through, the following ways:

    1. If you're using the PlayFab Master Collection, simply press F12 to open the Developer Tools : Console, I have a built-in debugger there if on PlayFab API : Debug Mode.
    2. If you're using AJAX or Scripting Feature, catch the Server Response of the error, and log the JSON data into the console through: console.log(responseJSON).

    You would then be able to know the error message and code.

    If you have the same Error 503 as mine. Here's what you can do to troubleshoot:

    1. Debug your .apk, then inspect your app from the Chrome :: Inspect Devices.
    2. Check for any mobile errors (red console logs), usually from a plugin not used on that platform, like the Facebook object (which is only used for web), situations like this can cause a connection error.
    3. If it's a Cordova plugin error, like a misconfigured Mobile Advert, Google Play, etc. It would show an error in the console, and your issue will be fixed once configured correctly.
    4. If the previous methods didn't work. It could be a depreciated Cordova plugin, filter out plugins you are using, until you find the one causing it, then file a bug report to the developer.
    5. If you can't still find anything wrong, time to go further. Lookout for broken scripts and filter out the common web plugins.
    6. If all else fails, you might want to make a small project, test out all plugins or scripts you use that could interfere with the network, in this case PlayFab.

    Good luck!

  • It's not a PlayFab issue, the same happens when I run http post request to any https service from Android APK. How can I trace the error? AJAX plugin doesn't seem to have a field with last error

  • If I run the same http post in remote preview on Android it works. It fails only when I run the request from the exported Android APK. Seems connected with this. Any ideas?

  • Ashley, when you say "mobile apps generally have to have any domains they communicate with specified in their configuration otherwise they are blocked by default." what do you mean? How can I do it?

    I mean, when I export the game as Android APK there is URL Whitelist field containing "http://*/* https://*/*". Is it enough or should I do something else?

  • By debugging the APK this is what I catch from the Console:

    [Construct 3] AJAX request to 'https://xxxxx.playfabapi.com/Client/LoginWithCustomID' (tag 'Login') failed:

    ProgressEvent

    isTrusted: true

    lengthComputable: false

    loaded: 0

    total: 0

    type: "error"

    target: XMLHttpRequest {readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, onreadystatechange: ƒ, …}

    currentTarget: XMLHttpRequest {readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, onreadystatechange: ƒ, …}

    eventPhase: 0

    bubbles: false

    cancelable: false

    defaultPrevented: false

    composed: false

    timeStamp: 5670.0999999993655

    srcElement: XMLHttpRequest {readyState: 4, timeout: 0, withCredentials: false, upload: XMLHttpRequestUpload, onreadystatechange: ƒ, …}returnValue: truecancelBubble: falsepath: []__proto__: ProgressEvent

    _TriggerError scripts/c3runtime.js:574

    xxxxx.playfabapi.com/Client/LoginWithCustomID:1 Failed to load resource: net::ERR_CACHE_MISS

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Guess it is because

    <uses-permission android:name="android.permission.INTERNET"/>

    is missing from the AndroidManifest generated? How to fix it?

  • I manually edited the AndroidManifest.xml to add the INTERNET permission and it worked!

    Why the export doesn't add that permission? Is it a bug? How to add it? I don't want to edit manually and resign the APK each time I export it

  • Try looking in the Network tab instead for any failed requests and see if there is any more information there about why the request failed.

  • I'm also investigating this at the moment. I think some endpoints on their API might have changed or something....

  • For what I posted before it seems that the exported apk lacks the permission to make request to the internet. By adding that permission it works. It was not a issue of playfab since I tried with other servers.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)