Search Unity

Issue with UnityWebRequest on iOS

Discussion in '2019.1 Beta' started by BBB_brunoma, Apr 8, 2019.

  1. BBB_brunoma

    BBB_brunoma

    Joined:
    Jan 10, 2017
    Posts:
    18
    Hello,

    I'm having an issue when sending a POST request using UnityWebRequest on iOS in 2019.1
    I'm using an UploadHandlerRaw and if the data is bigger than 2K, then the data gets truncated and never sent to the server resulting in a timeout error.
    The same code on Android and PC Editor works fine.

    I noticed in the release notes:

    iOS: UnityWebRequest will use new backend based on NSURLSession. Old NSURLConnection 
    backend is still available (commented out in trampoline).


    which seems kind of suspiciously related to my issue.
     
  2. BBB_brunoma

    BBB_brunoma

    Joined:
    Jan 10, 2017
    Posts:
    18
    Update: I managed to resolve the issue by turning off HTTP/2 support on the AWS Application Load Balancer I was connecting to.
     
    Charles_Beauchemin likes this.
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    2,247
    We don't support HTTP2. Maybe the iOS backend does, but our code doesn't, so funky results are expected.
     
  4. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    90
    I have the same problem. I'm sending data to AWS lambda backend. Android and Editor works fine, but IOS not.
    Here's the case number: (Case 1142166)

    (I haven't done anything fancy on AWS settings. Just simple API that accepts POST requests. (Note: Get requests works fine on IOS too)

    Workaround for me is to use HttpClient from System.Net.Http; namespace
     
  5. BBB_brunoma

    BBB_brunoma

    Joined:
    Jan 10, 2017
    Posts:
    18
    This is something you should look into though... most users won't have control over whether the server they are talking to has HTTP/2 support or not. From what I've been reading, NSURLSession will try to use HTTP/2 by default so you should either support it, configure it properly or not use it. A UnityWebRequest shouldn't break based on this.
     
    Fronne likes this.
  6. Simie

    Simie

    Joined:
    Oct 26, 2012
    Posts:
    369
    Fully agree. If HTTP/2 is not supported by Unity then they should make sure it's disabled on their end, not just break if the remote server tries to use HTTP/2.
     
    Fronne likes this.
  7. BlackclawsK

    BlackclawsK

    Joined:
    Jan 9, 2019
    Posts:
    2
    I ran into the same problem and spent multiple hours debugging this just now.

    Commenting in the old backend solved all related problems. This needs to become fixed soon or needs a default header for http2. This is real problem.
     
  8. BBB_brunoma

    BBB_brunoma

    Joined:
    Jan 10, 2017
    Posts:
    18
    Was just going through release notes and saw this in Unity 2019.1.4:

    iOS: Fixed larger than 2k payloads not sent by UnityWebRequest when HTTP/2. (1146305, 1152777)
     
    LeonhardP likes this.
  9. KosmoDED

    KosmoDED

    Joined:
    May 22, 2017
    Posts:
    8

    How exactly you commented backend?