iOS web request just hanging

I need to DL some JSON, but first things first. First, I want to just verify I have a connection on the iPad. This is what I do on Windows:

    IEnumerator IsConnected(Action<bool> action)
    {       
        UnityWebRequest request = UnityWebRequest.Get("http://www.readysetvr.com");
        yield return request.SendWebRequest();

        if (request.error != null)
        {
            action(false);
        }
        else
        {
            action(true);
        }
    }

On iOS (iPad mini) this never finishes. No timeout or anything. Works fine in Editor and on a MS Surface.

For quite a few years now Apple has required TLS secure transport.

Try it with an https:// URL and it should work.

Otherwise there USED to be a “allow non-TLS connections” property you could set in the plist file, but I think those days are over as far as production software goes.

I know you absolutely will have your app yanked from Google (ask me how I know!) if you state “We send all our data encrypted” and any part of your app is found to fire off a non-encrypted request.

Pretty sure it does not apply to good old Application.OpenURL() calls since that just forks the device browser.

1 Like

Thanks much! Using https:// fixed the problem with it hanging. But now request.error returns with ‘Unknown error’. Not too helpful. Works on Windows lol.

It shouldn’t have been hanging, but rather throwing an exception and the rest of the code not executing.
Your URL does not look correct, it should have a slash at the end.

Thanks! Trying it with a slash now, but could it be something with cloud build settings? Kurt mentioned the plist file - do I need to add some post-process script in advanced settings in cloud build? Saw some reference to this for allowing ‘unsafe’ urls?

We have a player setting for that. If you enable unsafe HTTP in there, we add the plist item for you.

Where is this in player settings? I can’t seem to find it.

Is it just the Allow ‘unsafe’ Code check box? I can’t find anything else related to unsafe.

No, that is completely different thing.
The setting is called “Allow downloads over HTTP”.

Got a pic or something? 2021.3.2f1 and I see no such thing.

So, that is HTTP… I am trying https and I still get “Unknown error”. Will this make any diff for https? Also I just don’t see that item in settings.

This is the (very simple) code I am currently trying. Adding a slash at the end makes no diff. Note https as well.

IEnumerator checkConnection(Action<bool> action)
    {
        UnityWebRequest request = UnityWebRequest.Head("https://www.readysetvr.com");
        request.timeout = 5;
        yield return request.SendWebRequest();

        if (request.error != null)
        {
            action(false);
        }
        else
        {
            action(true);
        }
    }

Also odd - your manual page under the Configuration section. Has the Allow downloads over HTTP explained, but it does not show in the screen shot for that section:

Bump

UnsafeHttp.png - Google Drive

Thanks but… maybe a little more info would be nice. I mentioned a few times that it’s not there - not in 2021.3.2f1 so when did it get added or what can I do in the version I am using? Also I asked - I am using https - will this do anything then?

Have you actually tried the “https://www.readysetvr.com**/**” ← note the slash at the end of url?

Yes, I have and it makes no difference and I just did another build to confirm. Still get Unknown Error. Would the ‘Allow http’ thing even matter for this and any idea why I don’t see it?

I installed 2021.3.22f1 and that also has no option for ‘allow downloads over http’. Can I please got some info on this?

So, am on Windows. I switched my build settings to iOS… and then I see that ‘allow unsafe http’ but it was already checked… So not sure it will do anything, but I saved the project, pushed to git, and am cloud building again.

As I suspected, that setting also does nothing - since I am using https. Of course.