Search Unity

UnityWebRequest "Unknown Error" from a specific computer

Discussion in 'Multiplayer' started by Adrien-Ninpo, Feb 28, 2019.

  1. HLMR

    HLMR

    Joined:
    Jul 9, 2019
    Posts:
    3
    Hello,
    I will join the discussion because I faced the same behaviour as others mentioned inhere already.
    In short:
    UnityWebRequest always brings a true flag on isNetworkError ("Unknown Error") in a local environment (self signed certificate for https) infrastructure and using IL2CPP scripting backend + https urls.

    When performing a UnityWebRequest to our application's Backend (ASP .NET Core) hosted on Azure, it works without any trouble so far.

    Using the exactly same code but built with .NET scripting backend in Unity, the UnityWebRequest performs successfully without any NetworkError in both cases, local environment and hosting on Azure (using https in both environments).

    Since the .NET scripting backend will be depreciated un Unity, we have to switch to IL2CPP and relay on it.

    I haven't tried to use this configuration yet but might do today or tomorrow:
    - local hosting environment
    - IL2CPP
    - HTTP (not https)

    The code built with Unity is beeing deployed to HoloLens (1) btw.
    InternetClient, InternetClientServer and PrivateNetworkClientServer capabilities are given.
    I'm using Unity 2018.3.14f1
     
    Last edited: Jan 30, 2020
  2. Saidbet

    Saidbet

    Joined:
    Feb 23, 2016
    Posts:
    9
    Hi.

    Same problem here on Unity 2019.1.0f2
    We have an app running on GearVr, Hololens. Hololens2 and Oculus Quest. (same code base)
    The app has worked without any problem so far on all of our devices (for 2+ years).

    A few days ago a client signaled he had a problem on a newly bought Oculus Quest. After investigations, he gets this "Unknown Error" on some API calls.
    We tested with his account on our own device and it works.
    We made him test on his device with our account and same problem.
    Which means the problem comes from his device or his network.
    The device is brand new.
    Don't have any info about the network.

    The strangest part is that one of the api calls works and the other don't.

    This is our generic ExecuteGet method.

    Code (CSharp):
    1. private static async Task<UnityWebRequest> ExecuteGet(string api, Dictionary<string, string> headers)
    2. {
    3.     var url = Path.Combine(baseUrl, api);
    4.     var req = UnityWebRequest.Get(url);
    5.     foreach(var header in headers)
    6.         req.SetRequestHeader(header.Key, header.Value);
    7.     await req.SendWebRequest();
    8.     return req;
    9. }
    And this api call works:
    Code (CSharp):
    1. public static async Task<ConnectionLink> GetConnectionLink(string deviceId)
    2. {
    3.     var res = await ExecuteGet(Path.Combine(DataAccess.webData.getConnectionLink, deviceId), new Dictionary<string, string>());
    4.     if (!string.IsNullOrEmpty(res.error))
    5.         return null;
    6.     return JsonConvert.DeserializeObject<ConnectionLink>(res.downloadHandler.text);
    7. }
    But this one doesn't:
    Code (CSharp):
    1. public static async Task<List<Project>> GetProjects()
    2. {
    3.     var headers = GetHeaders("application/json", CurrentSession.token?.access_token, CurrentSession.Organization.codename);
    4.     var res = await ExecuteGet(DataAccess.webData.getProjectsApi, headers);
    5.     if (!string.IsNullOrEmpty(res.error))
    6.         return null;
    7.     return JsonConvert.DeserializeObject<List<Project>>(res.downloadHandler.text);
    8. }
    The API is in production on Azure (Https)

    We asked him:
    • To make sure the device is up to date
    • To test on a different device
    • To test on a different network

    EDIT: After further tests. it was a firewall problem
     
    Last edited: Feb 7, 2020
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Check the Windows forum, there was a thread about certificate issues on Hololens. That have been resolve as I recall.
     
  4. madTeddy

    madTeddy

    Joined:
    Feb 1, 2016
    Posts:
    7
    Hello! I have a problem with UnityWebRequest on android devices. Very often (not every time) I see in the console Unknown error, but it's only on android devices, in editor all is fine. In the logcat I see this everytime:
    Last of course, it's mine Debug.Log message with UWP.error text in it. I send a POST request with WWWForm.
    Code (CSharp):
    1. using (var www = UnityWebRequest.Post(SERVER_URL + handlerName, postForm))
    2. {
    3.     www.chunkedTransfer = false;
    4.     www.timeout = timeout;
    5.     yield return www.SendWebRequest();
    6.     if (www.isNetworkError || www.isHttpError)
    7.     {
    8.         Debug.LogWarning("Leaderboard send error: " + www.error);
    9.         yield break;
    10.     }
    11. }
    Trying to enabling/disabling chunked transfer and http-continue, but nothing changes.
    Unity 2018.4.19f1
    Host Cloudways (may be it's help somehow)
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    This error usually is an indication of unstable network connection. Chunked transfer shouldn't have anything with it, HTTP-Continue can have some improvement, but in general I'd investigate network stability first (both server and phone).
     
  6. madTeddy

    madTeddy

    Joined:
    Feb 1, 2016
    Posts:
    7
    This error happening on 2 my test devices and emulator, and both on WiFi and mobile internet. On the host I didn't see any problems with connection in logs.
    And again, in editor all is fine.
     
    Last edited: Mar 27, 2020
  7. madTeddy

    madTeddy

    Joined:
    Feb 1, 2016
    Posts:
    7
    Tried to replace UnityWebRequest on third party plugin (HttpClient) and no errors. How unexpected!
     
  8. LLA830126

    LLA830126

    Joined:
    Sep 24, 2017
    Posts:
    1
    In my case, the file is not downloaded when it is https, but works normally only when it is http.
    It only happens on my macbook. It works fine on other computers.
     
  9. jencleary

    jencleary

    Joined:
    Oct 4, 2018
    Posts:
    4
    WILEz1975 Can you show how you did this workaround? I'm having the same problem with WebGL build. Works fine in dev build and android target, but I"m always getting IsNetworkError trying to access my php files. And how would you go about making a POST work?
     
  10. jhughes2112

    jhughes2112

    Joined:
    Nov 20, 2014
    Posts:
    178
    In case someone runs into this (like I just did), this might help. I have a web server that supports TLS1.2 (not 1.0, 1.1, or 1.3) and when the UWR code requests that file in 2018.4LTS it works fine. When I upgraded to 2019.1, it stopped working and gives me a isNetworkError and UnkownError with a 0 response code. Then I upgraded to 2019.4 and it started working again. Looks like something broken with 2019.1, at least.
     
    AminAghajoon likes this.
  11. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    This is roughly the time when support for TLS 1.2 was added. Most likely it was added to Unity after 2019.1 and was backported to 2018.3 (which later bacame .4LTS).
     
    AminAghajoon and jhughes2112 like this.
  12. codemaker2015

    codemaker2015

    Joined:
    Aug 19, 2018
    Posts:
    27