Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5 + Parse + iOS = NSURLErrorDomain error -1012

Discussion in 'iOS and tvOS' started by aparraga, Mar 9, 2015.

  1. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Hi,

    Seems like Unity 5 has a bug resulting in an NSURLErrorDomain error when trying to call the Parse API. According to what I have seen in other post from people with similar issues seems like this error happens with certain APIs (not just the Parse one) and Unity 5, but not with Unity 4.

    Do you have any workaround that I could use while you are fixing this issue? I need to continue working on Unity 5 (switching back to Unity 4 is not an option) with the Parse API asap.

    Please help!

    Thank you
    Antonio
     
  2. Psy_Duck

    Psy_Duck

    Joined:
    Jun 12, 2013
    Posts:
    9
  3. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    I see. Thank you for your clarification.
    Does anybody have any "non-production ready" workaround while you are fixing the issue? e.g. to use a proxy server to avoid ssl, anything else?

    Thank you
    Antonio
     
    Last edited: Mar 9, 2015
  4. vrm2p

    vrm2p

    Joined:
    Jul 23, 2014
    Posts:
    17
    we temporary stick to http (which is not an issue, since we're using AES encryption anyway).
     
  5. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Did you mean that you are calling Parse via http? how?

    thank you
     
  6. psyydack

    psyydack

    Joined:
    Aug 30, 2013
    Posts:
    93
    Can you share with us how to?
     
  7. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    Hi,
    The bug has been fixed and the fix will likely to be released in 5.0.0p3 and 4.6.3p4.
     
  8. Psy_Duck

    Psy_Duck

    Joined:
    Jun 12, 2013
    Posts:
    9
  9. alguemlegal

    alguemlegal

    Joined:
    Dec 18, 2013
    Posts:
    3
    Just installed the 5.0.0p3 and the error still occurs.
    I'm unable to deploy my app to my customers because of this!!!
     
    cryptoforge likes this.
  10. cryptoforge

    cryptoforge

    Joined:
    Jan 21, 2015
    Posts:
    60
    FIX THIS PLZ, I was also waiting for this.
     
  11. tapinator

    tapinator

    Joined:
    Apr 1, 2014
    Posts:
    4
    We thought this would be fixed with 5.0.0p3. But, we just tested and this is still not resolved.
    With which patch and when will it be fixed?
     
    cryptoforge likes this.
  12. miragine

    miragine

    Joined:
    Feb 25, 2015
    Posts:
    3
    I'm unable to deploy my app to my customers because of this!!!
    please fix it!
     
    cryptoforge likes this.
  13. vinhquang

    vinhquang

    Joined:
    Dec 11, 2014
    Posts:
    4
    I got this issue when try to load image from FB too. Without HTTPS it works well

    We really need it, please fix it soon.
     
    cryptoforge likes this.
  14. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    The bug we knew about in this case was corrected in 5.0.0p3. However, this might be something slightly different. If possible, please try using the Api Compatibility Level with a value of .NET 2.0 Subset (if you are not already). The Subset profile takes a different code path through the HTTPs code which might work better.
     
  15. vinhquang

    vinhquang

    Joined:
    Dec 11, 2014
    Posts:
    4
    Hi Josh,

    I have tried them all (with or without Subset), it's still there for iOS. This is what I do:
    Code (CSharp):
    1. IEnumerator downloadByUrl(string url, string pathFile, Action<string, WWW> actionCallback, bool loadLocal) {
    2.         bool isResult = true;
    3.         url = url.Replace("\\/", "/");
    4.         WWW www = new WWW("");
    5.  
    6. #if UNITY_WEBPLAYER
    7.         if (loadLocal == false) {
    8. #else
    9.         if (!File.Exists(pathFile) || loadLocal == false) {
    10. #endif
    11.             isResult = false;
    12.  
    13.             www = new WWW(url);
    14.             yield return www;
    15.          
    16.             if (www != null && www.error == null) {
    17.                 if (www.isDone) {
    18.                     byte[] data = www.bytes;
    19.                     if (data.Length > 0) {
    20.                         isResult = true;
    21. #if !UNITY_WEBPLAYER
    22.                         File.WriteAllBytes(pathFile, data);
    23. #endif
    24.                     }
    25.                 }
    26.             }
    27.         }
    28.  
    29.         if (actionCallback != null && isResult) {
    30.             actionCallback(pathFile, www);
    31.         }
    32. }
    Use whatever image from FB:
    Android is alright. Please give us some advises.
    Thanks
     
  16. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @vinhquang

    Thanks for trying these cases. I have one more for you to try (if you have not). Does this work with the Mono scripting backend? The original bug here was not specific to the IL2CPP scripting backend, but failed for both scripting backends. Thanks.
     
  17. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Does anyone have the Parse lib working with the p3?
     
  18. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @aparraga

    I've not tried the Parse SDK with any 5.0 releases yet. However, Parse v1.3.5 does work with the latest 4.6 patch release, so it is probably worth trying with the 5.0.0p3 release, as it has the same IL2CPP code at the 4.6.3p4 release.
     
  19. vinhquang

    vinhquang

    Joined:
    Dec 11, 2014
    Posts:
    4
    I have tried this thing and still got error:
     
  20. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @vinhquang

    Thanks again for trying this. Could you submit a new bug for this issue? It seems that we thought the issue was corrected, but it is not.
     
  21. cryptoforge

    cryptoforge

    Joined:
    Jan 21, 2015
    Posts:
    60
    This is the XCODE console output for a build made with 5.0.0p3.

    Code (CSharp):
    1. ParseUser error
    2. (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebug.gen.cpp Line: 56)
    3.  
    4. System.AggregateException: Exception of type 'System.AggregateException' was thrown.
    5. -----------------
    6. Parse.ParseException: The operation couldn’t be completed. (NSURLErrorDomain error -1012.)
    7.   at Parse.ParseClient+<>c__DisplayClass8.<RequestAsync>b__7 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
    8.   at Parse.Internal.InternalExtensions+<>c__DisplayClass1`2[System.Tuple`2[System.Net.HttpStatusCode,System.String],System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__0 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0
    9.   at Parse.Internal.InternalExtensions+<>c__DisplayClass7`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]].<OnSuccess>b__6 (System.Threading.Tasks.Task t) [0x00000] in <filename unknown>:0
    10.   at System.Threading.Tasks.Task+<>c__DisplayClass3`1+<>c__DisplayClass5[System.Threading.Tasks.Task`1[System.Tuple`2[System.Net.HttpStatusCode,System.Collections.Generic.IDictionary`2[System.String,System.Object]]]].<ContinueWith>b__2 () [0x00000] in <filename unknown>:0
     
  22. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Parse library works like a charm in editor mode, but it does not in iOS. In iOS it produces the NSURLErrorDomain error -1012 that I have started this thread with.
    Please, to reproduce just use the Parse library in your Unity project and try to store/retrieve data from Parse. Could you please fix it asap. I'm waiting to this patch in order to release my one-million dollars game!!! :)
     
    WolfBeardedLion and cryptoforge like this.
  23. Brock-Bondo

    Brock-Bondo

    Joined:
    Sep 21, 2013
    Posts:
    18
    It's not just parse api. The most basic use case is broken for iOS using just these simple lines over HTTPS. Which means you can't download any file over https.
    Code (CSharp):
    1. using(WWW download = new WWW(url)){
    2. while(!download.isDone) {
     
    cryptoforge likes this.
  24. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Sorry, I was mistaken. The fix for this issue did not make it into 5.0.0p3 as we expected. It should be in the next patch release for 5.0 though.
     
    cryptoforge likes this.
  25. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Nowadays all https API broken is a VERY BIG issue. For almost all of us is an stopper to go live.
     
    georgepiva and cryptoforge like this.
  26. georgepiva

    georgepiva

    Joined:
    Dec 16, 2013
    Posts:
    14
    When the next patch will be released? I am backporting my projects to Unity 4 just because of this BIG issue.
     
  27. goroid

    goroid

    Joined:
    Mar 30, 2015
    Posts:
    1
    This is a big issue for us too. Waiting for a next patch.
     
  28. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    Our next 5.0 patch release is scheduled to be 5.0.1p1 on April 15.
     
  29. DuaneCompton

    DuaneCompton

    Joined:
    Sep 22, 2014
    Posts:
    1
    Is there early access for a fix? Really appreciate any help here, its having a very direct impact on our ability to release multiple products. Anything please.
     
    georgepiva likes this.
  30. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    We're checking now to see what we can do. Stay tuned...
     
    georgepiva likes this.
  31. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    I'm interested also so please give info asap : (!
     
  32. wcorwin

    wcorwin

    Joined:
    Feb 7, 2014
    Posts:
    9
    I just merged a fix for this. You should be seeing it in 5.0.1p1
     
    cryptoforge likes this.
  33. Kirbyrawr

    Kirbyrawr

    Joined:
    Jul 23, 2012
    Posts:
    945
    When it will be ready more over? Thanks in advanced!
     
  34. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    The 5.0.1p1 release is scheduled for April 15.
     
    Kirbyrawr likes this.
  35. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    140
    Wait, you're saying that 5.0.1 will come out and this fix won't be in it?
     
  36. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @blueteak

    Yes, that is correct. The 5.0.1 release will include all of the fixes in 5.0.0p1, 5.0.0p2, and 5.0.0p3. It is really just a release to roll up all of the patch releases, with some additional testing done by our QA team. This is the normal process for patch releases and feature releases.
     
  37. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    140
    Gotcha, is there a chance that this fix won't make it into 5.0.1.1p? I am reporting to people higher than me and when I already said that official word was that this would be fixed last week in 5.0.0.3p, I have lost some credibility. I need to say something but I don't want to guarantee anything if this is going to be delayed again...
     
  38. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,920
    @blueteak

    Sorry, I understand this is a bad situation. Internally, the fix has been merged to our branch for 5.0.1p1, so we're pretty confident that it will be in. Since the fix is already in a 4.6 patch release, there is not too much chance we will need to back it out due to a regression. But with any fix, there is always a chance something will come up and we won't have it land where we think it will.

    Still, this one seems like as safe a bet as any.
     
  39. viedma

    viedma

    Joined:
    Mar 31, 2015
    Posts:
    3
    Guys, are you serious?

    This is a *major* bug that has been holding back the release of many apps (including 3 of ours). That Unity fails to make HTTPS requests is no joke and it has been reported over a month.

    Now you're saying it's going to take 1.5 months until a fix comes to the air? To be frank, this is really disappointing and a major issue.

    We will be reevaluating the usage of Unity3D in our company given the slow, incorrect (we were told this was fixed last week) and poor response the company is giving.
     
  40. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    There are instructions how to apply fix manually for Unity 5.0:
    1) Open Classes/Unity/WWWConnection.mm file in Unity generated Xcode project
    2) Locate there method called:
    Code (csharp):
    1.  
    2. - (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
    3.  
    3) Replace it with following implementation:
    Code (csharp):
    1.  
    2. - (void)connection:(NSURLConnection*)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
    3. {
    4.    
    5.    if ([[challenge protectionSpace] authenticationMethod] == NSURLAuthenticationMethodServerTrust) {
    6.      [challenge.sender performDefaultHandlingForAuthenticationChallenge:challenge];
    7.    }
    8.    else
    9.    {
    10.  
    11.      BOOL authHandled = [self connection:connection handleAuthenticationChallenge:challenge];
    12.  
    13.      if(authHandled == NO)
    14.      {
    15.        self->_retryCount++;
    16.  
    17.        // Empty user or password
    18.        if(self->_retryCount > 1 || self.user == nil || [self.user length] == 0 || self.password == nil || [self.password length]  == 0)
    19.        {
    20.          [[challenge sender] cancelAuthenticationChallenge:challenge];
    21.          return;
    22.        }
    23.  
    24.        NSURLCredential* newCredential =
    25.          [NSURLCredential credentialWithUser:self.user password:self.password persistence:NSURLCredentialPersistenceNone];
    26.  
    27.        [challenge.sender useCredential:newCredential forAuthenticationChallenge:challenge];
    28.      }
    29.    }
    30. }
    31.  
    Please let us know if it helps!

    P.S. This fix will be preserved with next builds in Unity when choosing Append action for Xcode project, but if you pick Replace action then it will be reverted.
     
  41. viedma

    viedma

    Joined:
    Mar 31, 2015
    Posts:
    3
    Mantas - thx for sharing that.

    We've tested it and it is working fine.
     
  42. AdamAtShernet

    AdamAtShernet

    Joined:
    Nov 13, 2014
    Posts:
    7
    Working for me as well Mantas, many thanks for providing this update!
     
  43. psyydack

    psyydack

    Joined:
    Aug 30, 2013
    Posts:
    93
  44. blueteak

    blueteak

    Joined:
    Feb 19, 2013
    Posts:
    140
    I love you so much it hurts, thanks for the fix!
     
    Aurore likes this.
  45. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    It works, finally. Thank you very much Mantas!
     
  46. aihodge

    aihodge

    Joined:
    Nov 23, 2014
    Posts:
    163
    Came here from a search for this same error. Mantas' fix did the trick for me too, thanks!
     
  47. di-lshod

    di-lshod

    Joined:
    Jan 15, 2013
    Posts:
    10
    Creating a file "Assets/Plugins/iOS/CustomConnection.mm", will fix the problem (http://docs.unity3d.com/Manual/iosCustomWWWRequest.html)

    Code (CSharp):
    1. #include "Unity/WWWConnection.h"
    2.  
    3. @interface UnityWWWCustomRequestProvider : UnityWWWRequestDefaultProvider
    4. {
    5. }
    6. + (NSMutableURLRequest*)allocRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers;
    7. @end
    8.  
    9. @implementation UnityWWWCustomRequestProvider
    10. + (NSMutableURLRequest*)allocRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers
    11. {
    12.     NSMutableURLRequest* request = [super allocRequestForHTTPMethod:method url:url headers:headers];
    13.    
    14.     // let's pretend for security reasons we dont want ANY cache nor cookies
    15.     request.cachePolicy = NSURLRequestReloadIgnoringLocalCacheData;
    16.     [request setHTTPShouldHandleCookies:NO];
    17.    
    18.     return request;
    19. }
    20. @end
    21.  
    22. @interface UnityWWWCustomConnectionDelegate : UnityWWWConnectionSelfSignedCertDelegate
    23. {
    24. }
    25. @end
    26.  
    27. @implementation UnityWWWCustomConnectionDelegate
    28. - (NSCachedURLResponse*)connection:(NSURLConnection*)connection willCacheResponse:(NSCachedURLResponse*)cachedResponse
    29. {
    30.     // we dont want caching
    31.     return nil;
    32. }
    33. - (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
    34. {
    35.     [super connection:connection didReceiveResponse:response];
    36. }
    37. @end
    38.  
    39. IMPL_WWW_DELEGATE_SUBCLASS(UnityWWWCustomConnectionDelegate);
    40. IMPL_WWW_REQUEST_PROVIDER(UnityWWWCustomRequestProvider);
    41.  
     
  48. WolfBeardedLion

    WolfBeardedLion

    Joined:
    Apr 5, 2013
    Posts:
    27
    Wow! You guys finally fixed it. Thank you. I had a lot of extra time to polish my game; glad I can finally release it.

    A lot of Unity games are going to drop on iOS in the next couple of weeks. ^_^
     
  49. SimteractiveDev

    SimteractiveDev

    Joined:
    Jul 9, 2014
    Posts:
    97
    Thanks for the fix Mantas! Probably not related, but I notice if you use ParseUser.LogOut(); it causes Unity to freeze the next time you attempt to enter Play Mode. Hopefully these will be fixed tomorrow.
     
  50. Mantas-Puida

    Mantas-Puida

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Do you have case number for that?