I have a simple GET request using UnityWebRequest that returns a JSON string from a URL. It works fine on Android but returns “Unknown Error” with a response code 0 on iOS. I have searched the forum and web for related issues but everyone seems to be talking about issues with POST. I am just doing a GET and it is very vanilla, ie (from memory as I am not in front of my dev machine)
UnityWebRequest www = UnityWebRequest.Get(“https://some-domain.org/?query=Production&start=0”);
yield return www.SendWebRequest();
if (www.isError || www.isNetworkError) {
Debug.Log(www.error);
}
Now this works fine on Android but not iOS. The only thing non-standard, and not covered in the examples, is the use of parameters in the URL. But I assume that is OK and, as I say, works in Android. Also note I am using https and not http (which should actually present less problems on iOS). I shall continue testing, eg remove parameters, but it is a slow process (build, transfer to XCode, build etc) and I am wondering if anyone has seen this issue before (again for GET not POST). This seems to be such a simple thing to do but is not working on iOS. I have tried allow unauthorised http and other settings in XCode but nothing helps.
I am using Unity 2018.3.12 and the iPhone testing on is iPhone 6. It does not have a SIM but is connected to a WiFi network and I can successfully browse to the URL in question and see the correct response. I do a test for network connectivity before sending the request, which returns that the internet is reachable.
Is that same URL accessible via HTTP instead of HTTPS?
Trying to rule out the security.
Also, have you tried Unity 2019.1? UWR backend was rewritten in that release.
I have been reluctant to upgrade as I am close to a release deadline and going to 2019.1 may introduce more problems to solve, eg it will force me into Unity Hub and with Hub it seems that you cannot run Unity as Administrator. I may have to setup a test environment tho on another machine and try it.
I will try http and see, but I think it might have more to do with being on a WiFi and not using mobile data so I am trying to find a test iPhone with a SIM.
That sounds strange. All my tests on iPhone we done using WiFi on devices without SIM.
My suggestion was not to upgrade Unity, just try to perform the same request on newer version to see, if it’s an issue with the backend on 2018.3 (which was rewritten in 2019.1).
Oh OK, thanks for that. It is good to know that it should work on WiFi without SIM, so I can eliminate that.
Yes, I will try and setup a minimal test case on 2019.1 and see if it works.
Thanks for the input.
I tried on 2019.1.10f1 and it works as expected. I should have started my minimal test in 2018.3 first to see that it wasn’t working (in case it is something else in my project) then go to 2019.1.10.
Before upgrading I might do that just to make sure it is a problem in 2018.3 and not something else.
Ok, I setup a clean minimal project in 2018.3.12 that just sends the UnityWebRequest with the exact same code I used in the 2019.1.10 project. It works in 2019.1.10 but not in 2018.3.12 so it looks like the rewrite of the backend of UnityWebRequest has solved the problem. Now I need to decide if I risk other unknowns by upgrading the project, maybe to be safe I will do that in a fork of the project on a different machine.
Thanks for your help @Aurimas-Cernius
Ok, so I got a reply to say it has been fixed in 2019.1 and up!
So I have upgraded (which I was trying to avoid) and now, predictably, I cannot build to iOS at all.
Very frustrating.
Working in Unity 2018.1.0b13 for quite some time already
The game runs smoothly on Android and iOS
I work on windows so for iOS I generate the xCode project locally, then I transfer it to my remote mac desktop to build on xCode
I had my assetbundles stored on my online storage provider - a local company in my country (which is super cheap) at http://sub.domain.com/AssetBundles/bundle1
Down comes the requirement to add Firebase cloud messaging a.k.a. remote push notifications. This meant I had to update to something newer. I know the Unity xxxx.4.7 releases are the end-of-cycle versions, thus usually being the most bug-free versions of unity. So I went with Unity 2018.4.7f1
tl;dr After:
Updated to Unity 2018.4.7f1
added Firebase messaging unitypackage
generated xCode project on my windows and moved to my remote mac desktop
on my mac I need to run pod install in my project folder before I continue (firebase sdk requirement if you build on widows)
if I run pod install, then build and test my iOS app - it doesn’t download my assetbundles!
if I don’t build with Firebase and don’t run pod install (meaning no push notificaitons for my app) it works just fine, so I can’t blame it on Unity
100 centuries pass trying to figure out what’s going on
I randomly move one of my assetbundles to my company’s AWS S3 storage and it gets downloaded!
url is like https://my-app-bucked.s3.eu-central-1.amazonaws.com/AssetBundles/bundle1
I have no clue what was wrong with our previous storage provider but this worked for us. This was not a http/https issue, not a GET/POST request issue, nothing of I could think of because all other requests worked just fine EXCEPT those GET requests to download assetbundles.
The AWS free tier seems to cover us for now. So I got this going for myself which is nice.
I know this is might not be your case but sharing is caring