Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

2019.2 Issue with Application.internetReachability for Android

Discussion in 'Android' started by DevPitaya, Aug 12, 2019.

  1. DevPitaya

    DevPitaya

    Joined:
    Feb 12, 2018
    Posts:
    5
    Hello,

    I use "Application.internetReachability" to check if the game client has internet access for many reasons in my game.

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class Example : MonoBehaviour
    4. {
    5.     string m_ReachabilityText;
    6.  
    7.     void Update()
    8.     {
    9. //Output the network reachability to the console window
    10.         Debug.Log("Internet : " + m_ReachabilityText);
    11.         //Check if the device cannot reach the internet
    12.         if (Application.internetReachability == NetworkReachability.NotReachable)
    13.         {
    14.             //Change the Text
    15.             m_ReachabilityText = "Not Reachable.";
    16.         }
    17.         //Check if the device can reach the internet via a carrier data network
    18.         else if (Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork)
    19.         {
    20.             m_ReachabilityText = "Reachable via carrier data network.";
    21.         }
    22.         //Check if the device can reach the internet via a LAN
    23.         else if (Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork)
    24.         {
    25.             m_ReachabilityText = "Reachable via Local Area Network.";
    26.         }
    27.     }
    28. }

    Before upgrading to 2019.2: it would worked fine before upgrading.

    After upgrading to 2019.2: it would return = "NetworkReachability.NotReachable" but only at the initial app launch.

    After putting some debug steps in, I was able to see that the time it takes for the client to recognize the internet connection varied. Sometimes it would recognize the connection right away but other times it showed as "NotReachable" for up to 10 seconds until being recognized.

    I need it to be able to recognize the connection right away. Has anyone else experienced any issues with this delay?

    Can anyone shed some light on this issue?





    After upgrading to 2019.2
     
    Last edited: Aug 12, 2019
    shacharoz, ina, andreyul and 2 others like this.
  2. mikapote

    mikapote

    Joined:
    Oct 24, 2018
    Posts:
    28
    Thanks for this DevPitaya, I thought I was the only one (and hence that I messed up something in my code!). Same issue since upgrading to 2019.2.
     
    ina likes this.
  3. thordickinson

    thordickinson

    Joined:
    May 16, 2017
    Posts:
    1
    Same thing here...
     
  4. DevPitaya

    DevPitaya

    Joined:
    Feb 12, 2018
    Posts:
    5
    Thanks for confirming this issue @mikapote @thordickinson . Can we get some insight from the Unity team on this please? Is there a workout/fix?
     
    ina likes this.
  5. MikePage_Artrix

    MikePage_Artrix

    Joined:
    Mar 18, 2016
    Posts:
    15
    Happening here to 2019.2
     
    ina likes this.
  6. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    83
    same here
     
    ina likes this.
  7. Meepolisk

    Meepolisk

    Joined:
    Jan 2, 2016
    Posts:
    1
    same here :( i got doomed the whole day until i found out this thread
     
    ina likes this.
  8. tribio

    tribio

    Joined:
    Oct 5, 2013
    Posts:
    29
    same here
     
    ina likes this.
  9. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    106
    Seeing this on Oculus Quest with Unity 2019.2.5f1. This call has worked reliably for several years. At a minimum, if the underlying logic has changed, that should be expressed in a new API so that existing code doesn't break.
     
    ina likes this.
  10. bigcupof

    bigcupof

    Joined:
    Nov 13, 2014
    Posts:
    1
    We got the same issue, did anyone find a working solution for this?
     
    ina likes this.
  11. jscottartrix

    jscottartrix

    Joined:
    Dec 15, 2017
    Posts:
    2
    @alexidr until it's fixed in Unity again you could try a different means of checking internet availability, like using a Ping object to ping something you know will get a response (like Google's DNS, 8.8.8.8). That solution is a bit annoying as you have to wait for a response to the ping whereas you can always read Application.internetReachability. Also, if your app hangs while loading a ping can fail, so it's a good idea to verify a failed ping by sending another one. Two fails means most likely no internet.
     
    ina likes this.
  12. arjun19

    arjun19

    Joined:
    Jul 4, 2018
    Posts:
    2
    Happening with 2019.2.6
     
    ina likes this.
  13. dominykasm

    dominykasm

    Unity Technologies

    Joined:
    May 27, 2018
    Posts:
    70
  14. nestorjulian2

    nestorjulian2

    Joined:
    Jan 24, 2019
    Posts:
    2
  15. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    Which Fixed in 2019.2 has it been fixed in? Currently using 2019.2.2f1 and experiencing this for both Pixel XL 2 and OnePlus normal Android phones
     
  16. JuliusM

    JuliusM

    Unity Technologies

    Joined:
    Apr 17, 2013
    Posts:
    836
    It was fixed in 2019.2.11f1, however it is recommended is to use the latest available 2019.2 version.
     
  17. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    78
    dan_ginovker and justtime like this.
  18. Miro280

    Miro280

    Joined:
    Jun 20, 2017
    Posts:
    1
    I found solution for Application.internetReachability always not reachable at the start of app on Android (which worked correctly on PC). I just called it in empty if in Start() and right after it I called it again in coroutine which contained also webrequest but I think it would work even outside of coroutine.

    if (Application.internetReachability == NetworkReachability.NotReachable)
    {

    }
    StartCoroutine(getRequireInternet());
     
    Last edited: May 7, 2020
  19. shacharoz

    shacharoz

    Joined:
    Jul 11, 2013
    Posts:
    98
    I don't know guys.
    I'm using unity 2020 LTS and I still have the same issue.
    I'm now ignoring this variable at all, as it seems not working and not so useful.
    i will try to only check the ping.