Search Unity

  1. We've closed the job boards. If you're looking for work, or looking to hire check out Unity Connect. You can see more information here.
    Dismiss Notice
  2. Unity 2017.2 is now released.
    Dismiss Notice
  3. The Unity Gear Store is here to help you look great at your next meetup, user group or conference. With all new Unity apparel, stickers and more!
    Dismiss Notice
  4. If you're a macOS 10.13 High Sierra user take be sure to read this before updating Unity.
    Dismiss Notice
  5. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  6. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice
  7. Unity 2017.3 beta is now available for download.
    Dismiss Notice

Internet Reachability Verifier - Support Thread

Discussion in 'Assets and Asset Store' started by tonic, Jun 19, 2014.

  1. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Big update! - Version 1.1.0 is now available:
    • Changed internal coroutine to wait using realtime instead of pauseable normal time.
    • Also the getTimeWithoutInternetConnection is now realtime-based.
    • Added forceReverification method which sets status to pending verification, which is also now internally noticed immediately.
    • Exposed the time value settings to inspector.
    • Added AppleHTTPS method (due to ATS, App Transport Security).
    • Added waitForNetVerifiedStatus convenience helper coroutine.
    • Fixed regression bug of running verification twice.
     
  2. invictvs1

    invictvs1

    Joined:
    Mar 7, 2014
    Posts:
    14
    Hi tonic,

    We have found a few issues with IRV. The biggest one we are facing now is that in Desktop Standalone builds the example doesn't seem to be working. I am disabling and re-enabling my network adapter with no change. I am doing a simple build of the example scene that is provided. The only way I am able to get it to recognize the change is forcing reverification, but that's not an ideal solution. Any idea why this could be? We are on 5.4.1p1.

    Any help is greatly appreciated!
     
  3. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi @invictvs1,

    Thanks for asking. I'm not fully sure I understood what exactly isn't working for you, but it sounds to me like you're expecting the status to change to "offline" after the network connectivity has already been verified?

    Normally desktop machines are never totally "offline", as is documented by Unity for the Application.internetReachability: "Non-handhelds are considered to always be capable of NetworkReachability.ReachableViaLocalAreaNetwork". The Internet Reachability Verifier (IRV) asset uses that to determine if there's even point trying to verify actual internet connectivity.

    It's important to note that IRV is used only for verifying when the online internet connectivity works -- active monitoring of "online --> offline" is not a feature of IRV. This is because monitoring for that would require some constant network traffic, and that would be actually impolite(*) towards end-users, since it would be "unnecessary" traffic. Instead of that "unnecessary" traffic, a developer is expected to simply monitor for error situations when they're using network -- which is normally done anyway (or should be done). When you can figure out from the errors that e.g. connection was cut off, then you can manually request for the reverification.

    So to recap:
    1. IRV monitors when online connectivity is available (this is the main feature of the asset). This can be done "constantly" without causing network traffic, so it is an effective way.
    2. After network connectivity is verified, IRV basically does nothing. (Except on mobiles the device can go to offline state e.g. when going to airplane mode including WiFi off; in such case IRV will go to that step 1).
    3. When networking is verified, you do stuff in the net (e.g. using WWW class, or some other means of networking). In case of failure, you're supposed to look at error codes, and if determined to be necessary, ask for IRV to reverify the connectivity (that is, go back to that step 1).

    Hope this helps! If I understood you wrong and your problem is different, please re-explain how the built-in examples are not working and I'll try to figure it out.

    ---
    * (Edit) forgot to mention that the unnecessary traffic would be impolite because in many places users still have to pay by amount of used traffic.
     
    Last edited: Oct 11, 2016
  4. invictvs1

    invictvs1

    Joined:
    Mar 7, 2014
    Posts:
    14
    This definitely helps, and you understood my question correctly. Makes a lot of sense now, thanks for the clarification. I will rework our IRV implementation in the application and see if it resolves my problem.
     
  5. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    55
    I just upgrade and I am getting this error now.

    IRV www error: Protocol " https" not supported or disabled in libcurl

    and if I change to http
    IRV www error: Protocol " http" not supported or disabled in libcurl

    It is only using the custom method, when I choose https apple it works.
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @phoenixrising, make sure you have correctly written the URL, it looks like you have extra space at the beginning?
     
  7. phoenixrising

    phoenixrising

    Joined:
    Aug 9, 2013
    Posts:
    55
    Wow, I feel stupid, yup that fixes it! Thanks!
     
  8. Priyanka-Rajwanshi

    Priyanka-Rajwanshi

    Joined:
    Nov 22, 2013
    Posts:
    7
    Does it support IPV6 for iOS? Confirm?
     
    Last edited: Oct 26, 2016
  9. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @Priyanka-Rajwanshi I think it should work just fine, but haven't verified in IPv6-only network. No direct IP (v4) addresses are used, and the verification uses standard http/https connections using UnityEngine.WWW, so I am almost sure there's no problem.
     
  10. Priyanka-Rajwanshi

    Priyanka-Rajwanshi

    Joined:
    Nov 22, 2013
    Posts:
    7
    Okay. Thank you :)
     
  11. Wajdik

    Wajdik

    Joined:
    Feb 4, 2015
    Posts:
    174
    Hi,
    I noticed that you didn't update this plugin since August, are you still supporting it?
    And are you planning to add more features/improvements soon?
     
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @Wajdik, yes, still supporting, like you can see from the August update. Previous one was over a year earlier, as this asset does not require frequent updates.

    There are no big feature additions planned. Do you have something in mind?
     
  13. Wajdik

    Wajdik

    Joined:
    Feb 4, 2015
    Posts:
    174
    Hi,
    You can add a way to check the connection periodically, for example if we use (www.msftncsi.com/ncsi.txt) to check the Internet connection it will not consume any noticeable bandwidth.
    You can add this feature and let the developers to decide to use it or not!
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @Wajdik, it's true that the bandwidth use is quite small for periodic checks.

    So far I have left out for periodic check out of principle, for these reasons:
    1. It still uses the bit of bandwidth every now and then, and there are users with mobile contracts where every bit of user bandwidth still has a cost (admittedly cost of reasonably done periodic check is negligible for relatively short sessions).
    2. It is technically unnecessary. If connectivity is lost, it is always best to detect that by looking at error status from the networking operation you're doing at the moment, which is what is encouraged in this asset's docs as well (and at that point you can request for re-verifying of the net connection, to wait for a notification when it's deemed to work again). Using periodic check might encourage sloppy coding where errors are not checked for.
    That being said, I'm sure there are some use cases where above points are no concern. I will consider this for a future update as an optional feature. I have busy times right now, so I can't give a promise when next version will be out.
     
  15. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Version 1.1.1 released, containing minor usability improvements: tooltips and a custom inspector which can give some in-editor warnings of unsuitable configuration. (periodic check feature discussed above has not been added in this version)
     
  16. Johnny-Ow

    Johnny-Ow

    Joined:
    Mar 3, 2015
    Posts:
    8
    Any known incompatibility with iOS 10.3.1 or XCode 8.3.1? I updated XCode today and noticed that IRV (1.1.0 and 1.1.1) stopped working with the default validation method on iOS (Apple HTTPS). Apple and Apple2 still works.
     
  17. Demanuele

    Demanuele

    Joined:
    Sep 18, 2015
    Posts:
    16
    Same problems here on iOS. Looks like Apple changed their html doc so this fails:
    Code (CSharp):
    1. int successPos = www.text.IndexOf("<BODY>Success</BODY>");
    2.                 if (successPos >= 0 && successPos < 50)
    3.                     return true;
    Very easy to fix the plugin but do you think we could get Apple to fix this for now?
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Thanks for reporting the issue. It's an unfortunate change on the page returned for the AppleHTTPS method.

    This is fixed in the v1.1.2 hotfix release so please update to it immediately. It contains a bit looser/varied check for the Apple methods which hopefully prevents incidents like this for the future.

    Unfortunately I don't have a valid contact which would be reasonable enough to ask for an immediate fix for this kind of thing. So I believe the quickest way to work around this is to just update an app. If you have an apple representative contact, then you can ask them to expedite the update for your app.
     
  19. Wat123

    Wat123

    Joined:
    Aug 31, 2015
    Posts:
    5
    Hi tonic,

    I'm using your internet verifier plugin in iOS but today suddenly it is giving me PendingVerification and mismatch status and showing error. Thus not able to play my Game. This problem is occuring only on iOS, Android build is runnning fine.
     
  20. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi @Wat123, as stated above, you need to update your app to use the v1.1.2.
     
    Demanuele likes this.
  21. akajb

    akajb

    Joined:
    Feb 13, 2017
    Posts:
    1
    Hi @tonic

    The company I work for uses IRV in our app. And we seem to be running into the problem above. However, it appears that an old team member who is no longer with the company bought the license through their account (bought for the company use). So I'm just wondering if there's a way to upgrade our code without their account. Or if we're going to need to buy a new license.

    Thanks!
     
  22. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @akajb, I'll send you a private message about this.
     
  23. Dm-Smirnov

    Dm-Smirnov

    Joined:
    Oct 30, 2013
    Posts:
    4
    Hello, @tonic.
    I use your IRV but on iOS i get always "Offline" state.
    I updated IRV to 1.1.2, but still "Offline".

    How solve problem?
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi @Dm-Smirnov!
    Can you please verify again that your project really has the latest version 1.1.2, and that your build is using the version? Perhaps delete the InternetReachabilityVerifier from project and import latest version again from the asset store.

    Version 1.1.2 should work fine, but earlier versions have stopped working on iOS when using the AppleHTTPS method.
     
  25. PetroUnityDev

    PetroUnityDev

    Joined:
    Nov 19, 2014
    Posts:
    5
    Hi @tonic!

    I have found that the plugin does not work properly on Desktop platforms due to the netActivity coroutine using Application.internetReachability to detect a network change and force the status to PendingVerification. Unfortunately, Application.internetReachability seems to always be ReachableViaLocalAreaNetwork on non-handheld devices.

    The test case I am working through occurs when starting my game with an active internet connection and cutting the connection in the middle of the game. The plugin never detects the connectivity change.

    Is there a workaround/fix for this issue?
     
  26. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi @PetroUnityDev, what you describe about Application.internetReachability being limited that way is the very reason this asset even exists. :)

    In Internet Reachability Verifier (IRV), the Application.internetReachability is only used as the "first step" to determine if there's point at all trying to verify the connectivity using an actual connection. If that passes, then the actual http(s) request is used to the place determined by selected captive portal detection method. The detection would work even without that "first step", it's just an optimization.

    The asset only features verifying that there is connectivity when asked for that. It does not actively monitor for connection being lost. There's two reasons for that:
    (1) Active monitoring with the same detection method would mean polling with http requests repeatedly, and that would lead to unnecessary network traffic. That'd be impolite towards user, since some still have to pay for their bandwidth (applies especially mobile networks). (Note that when the network doesn't work, polling with requests is ok, since they don't go anywhere, and when it finally does, it's about as small request as it could be).
    (2) After you know the network works, you're going to do some other networking, with whatever API you're using. It's much better way to detect network loss by checking the error/return codes from that API -- you're supposed to check for the errors anyway. And that's the fastest way to know that network went down, rather waiting for a different component realizing it by polling.

    Then, when you realize that you've lost connection, then the expectation is that you manually force the IRV again to the PendingVerification state (call forceReverification()). It will then keep trying until the connection is verified again for the moment.

    Hope this helps!
     
  27. TheKingOfTheRoad

    TheKingOfTheRoad

    Joined:
    Apr 24, 2013
    Posts:
    18
  28. SuperbStarling42

    SuperbStarling42

    Joined:
    Jan 15, 2014
    Posts:
    4
    Hi - I am again getting connection issues on iOS, and am already using the v1.1.2 hotfix .
    It is odd, because if I use the Fiddler proxy tool to test the connection when "Decrypt HTTPS traffic" is enabled, then the connection response is correct, and the app finds a connection.
    However with this disabled, the app cannot find a connection.

    Anybody else experiencing this issue?

    I can resolve this issue by resetting the settings on the device - however I do not understand what caused this issue ( nb this happened on multiple devices)
     
    Last edited: Oct 2, 2017
  29. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi @SuperbStarling42, just tried but can't reproduce the issue here. Everything seems to be fine. Care to give some more specifics like Unity and iOS version?
     
  30. rgonsalv

    rgonsalv

    Joined:
    Sep 29, 2016
    Posts:
    13
    Have there been any errors reported against Unity 2017.2.0f3? Just updated to latest version of IRV to try to fix. I am seeing the following in Android logcat:

    Code (csharp):
    1. 10-12 14:27:45.829 27536-27573/<our app package> E/Unity: NullReferenceException: Object reference not set to an instance of an object
    2. at UnityEngine.WWW.get_responseHeaders () [0x00076] in /Users/builduser/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:158
    3. at InternetReachabilityVerifier.checkCaptivePortalDetectionResult (CaptivePortalDetectionMethod cpdm, UnityEngine.WWW www) [0x000e9] in /Users/lcadev/Documents/Unity/OurApp/Assets/InternetReachabilityVerifier/InternetReachabilityVerifier.cs:316
    4. at InternetReachabilityVerifier+<netActivity>c__Iterator1.MoveNext () [0x00294] in /Users/lcadev/Documents/Unity/OurApp/Assets/InternetReachabilityVerifier/InternetReachabilityVerifier.cs:459
    5. at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00028] in /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17
     
  31. Nadan

    Nadan

    Joined:
    Jan 20, 2013
    Posts:
    273
    I'm getting the same error:

    Code (csharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEngine.WWW.get_responseHeaders () (at C:/buildslave/unity/build/Runtime/WebRequestWWW/UWRWWW.cs:158)
    3. InternetReachabilityVerifier.checkCaptivePortalDetectionResult (CaptivePortalDetectionMethod cpdm, UnityEngine.WWW www) (at Assets/InternetReachabilityVerifier/InternetReachabilityVerifier.cs:316)
    4. InternetReachabilityVerifier+<netActivity>c__Iterator1.MoveNext () (at Assets/InternetReachabilityVerifier/InternetReachabilityVerifier.cs:459)
    5. UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
    I have Unity 2017.2.0f3.
     
  32. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Hi, thanks for the reports, I'll investigate this!
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @rgonsalv & @Nadan, it seems Unity has replaced the implementation of WWW class internally. Their new implementation doesn't seem to fill in response http headers when http result is 204. This means there's a regression bug which makes latest Unity version incompatible with the "Google204" detection method of IRV.

    Workaround: For now, just force the asset to use a different method instead of "DefaultByPlatform", for example "GoogleBlank" or "MicrosoftNCSI".

    I'll solve this for next release some way, so that the asset will work again "out of the box".
     
  34. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    I reported this implementation issue as a bug to Unity and they already reproduced it & sent to be fixed (apparently). There was no idea when it'll be fixed in Unity though, so unless it is patched very quickly, then I'll make a release at some point with a workaround.
     
  35. rgonsalv

    rgonsalv

    Joined:
    Sep 29, 2016
    Posts:
    13
    The problem appears to start in 2017.1.2, fwiw. Thanks for attending to it.
     
  36. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
  37. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    @rgonsalv & @Nadan, seems like Unity has fixed the regression bug in Unity 2017.1.2p2 (also checked it works in 5.6.4p1).
     
    Harha-Studios likes this.
  38. Harha-Studios

    Harha-Studios

    Joined:
    Apr 5, 2014
    Posts:
    1
    Seems to work with Unity 2017.2.0p1 too. :)
     
  39. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    334
    Harha-Studios likes this.