Search Unity

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:
    4
    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
    ina, andreyul, alexidr and 1 other person like this.
  2. mikapote

    mikapote

    Joined:
    Oct 24, 2018
    Posts:
    24
    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:
    4
    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:
    11
    Happening here to 2019.2
     
    ina likes this.
  6. robertsze

    robertsze

    Joined:
    Jul 8, 2013
    Posts:
    64
    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:
    25
    same here
     
    ina likes this.
  9. rchapman

    rchapman

    Joined:
    Feb 13, 2014
    Posts:
    50
    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. alexidr

    alexidr

    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:
    66
  14. nestorjulian2

    nestorjulian2

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

    ina

    Joined:
    Nov 15, 2010
    Posts:
    847
    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:
    474
    It was fixed in 2019.2.11f1, however it is recommended is to use the latest available 2019.2 version.
     
unityunity