Search Unity

RestAPI - post method string size limitations

Discussion in 'iOS and tvOS' started by SplashFoxGames, Jun 17, 2019.

  1. SplashFoxGames

    SplashFoxGames

    Joined:
    Oct 10, 2012
    Posts:
    53
    Good day, dear developers!

    Can you please advice on next:

    I have in-app purchases. I validate it using backend server. So once a purchase successfully done on iOS - I have a 4k+ string - hash code of the receipt that I need to sent to my backend server via RestAPI (POST method).
    I can send this string from Editor (hardcoded hash), thats fine for Android as well, but on iOS platform it seems there is some limitation of json string I can send using POST method... ? the request just stuck and return code = 0 after half minute or so.
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    Sounds like a bug we recently fixed. It's an issue we had with HTTP/2 (though it's possible it could occur with 1.1 too).
    If you don't want to upgrade, you have two options to manually fix it:
    - in exported XCode project modify UnityWebRequest.mm and increase the buffer size
    - in exported XCode project uncoment old backend in WWWConnection and comment out the new one
     
  3. SplashFoxGames

    SplashFoxGames

    Joined:
    Oct 10, 2012
    Posts:
    53
    Thanks, I'm using Unity 2019.2.Alpha14 build. Will check what you propose and let you know within a day-two
     
  4. SplashFoxGames

    SplashFoxGames

    Joined:
    Oct 10, 2012
    Posts:
    53
    yes, I changed one value from 1024 to 8192 and seems working now (and uncommented some things). From another side - for sure the fix will be included in 2019.2.f1 right ?
     
  5. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    A 4K receipt? Is this a tester account perhaps with hundreds of purchases? Apple typically returns all receipts. Or does this happen on a new tester account with a single purchase?
     
  6. SplashFoxGames

    SplashFoxGames

    Joined:
    Oct 10, 2012
    Posts:
    53
    4480 chars takes the hash-code string - single consumable purchase 1 product id by 1 user
    then backend send this to receive information about the purchase (much smaller data) to Apple verification service/site. Sand-box mode.
    I receive this string from Apple after test purchase successfully done and then my backend send it to https://sandbox.itunes.apple.com/verifyReceipt

    in answers here you can see a sample of the looooong receipt string : )
    https://stackoverflow.com/questions/33843281/apple-receipt-data-sample

    I also tried to hardcode this string and send from Unity Editor and Android build - all is good there, the limitation is only on iOS build
     
    Last edited: Jun 19, 2019
  7. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it! Yes, I wasn't aware that it's so long