Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    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:
    427
    NEW in v1.2.0: :D
    WebGL and Facebook platform support.
    • Support for Android 9 security config, where cleartext http traffic is disabled by default (similar to iOS ATS).
    • Compatibility verified up to Unity 2018.3.
    New detection methods: Google204HTTPS, UbuntuHTTPS, MicrosoftConnectTest, MicrosoftNCSI_IPV6, MicrosoftConnectTest_IPV6 (the IPV6 ones only work when the network is IPV6-capable!).
    UnityWebRequest is now used with Unity 2018.3+

    ( Ping @Murcho @Mandelboxed @dasu @rebbort )
     
  2. chaostheorygames

    chaostheorygames

    Joined:
    Jul 10, 2014
    Posts:
    11
    Hi @tonic
    Is there any reason the minimum API level is set so high (Android 8.0, API level 26)?
    We are building a game that requires Android 6.0, API level 23 - have just purchased and implemented your plugin and it is stopping us from building to device.
     
    Indroo likes this.
  3. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @chaostheorygames is that for the included AAR file (containing network security config)?
    If so, it's probably my mistake and there's no reason to set it that high. I can't verify this right now, but I will soon!
     
    Indroo likes this.
  4. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @chaostheorygames I think that it's because of the aar file. I sent you privately a new one, hoping you can test if it works with your build.
     
  5. chaostheorygames

    chaostheorygames

    Joined:
    Jul 10, 2014
    Posts:
    11
    Thank you that fix worked! Much appreciated.
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Version 1.2.1 is released and it lowers the minimum / target SDK requirements.
     
  7. NandhuVicky

    NandhuVicky

    Joined:
    Oct 1, 2018
    Posts:
    2
    @tonic
    Question regarding IRV feature

    Does IRV have any feature like slow internet connectivity monitor that detects slow internet connection at runtime?
     
  8. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi @NandhuVicky, thanks for the question. There's no any kind of speed monitoring involved.
     
  9. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    94
    Hi @tonic
    I have problems with checking the internet on Android 9. I have the latest version of your plugin, but it doesn't work on Android 9.

    P.S.: iPhone works. Other Android versions work. Unity 2018.2.
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @Shefich Since proper Android 9 support was added in version 1.2.0, could you provide more details?

    - which version of IRV you're using
    - what Unity version you're using
    - what Android SDK version you are using (and targeting what version)
    - what IRV detection method you're using - default by platform, or one of the others (which one / provide your custom url if you use custom method, you can send that in private message)
    - did you notice anything specific when monitoring adb logcat
     
  11. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    94
    @tonic
    - IRV 1.2.1
    - Unity 2018.2.21 f1
    - Minimum Android API 4.1
    - Target automatic (highest installed) Installed highest = 9.0
    - On Android 9 OneUI 1.0 doesn't work
    - On Android 8.0.0 works
    - IRV detection Default by platform
    - adb logcat:
    Cleartext HTTP traffic to clients3.google.com not permitted

    Upd:
    Adding android:usesCleartextTraffic="true" to the AndroidManifest fixes the problem, but I have no idea why your network security configuration file (aar) doesn't work.
     
    Last edited: Apr 26, 2019
  12. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @Shefich, thanks!

    There's a few things we could try:

    1. Update to Unity 2018.3 or newer. If you can't upgrade, then alternatively please try to enable UnityWebRequest usage: Find #define IRV_USE_WEBREQUEST in InternetReachabilityVerifier.cs, remove the preceding #if and the next #endif. (This step is bit of a wild guess, and should not affect...)

    2. Make sure this file is in your project and not somehow omitted:
    Assets/InternetReachabilityVerifier/Plugins/Android/InternetReachabilityVerifier_NetworkSecurityConfig.aar
    Also click that file in Unity Project window and make sure in Inspector that the Android platform is [✓] Checked. This file is crucial for the Android 9 support.
    I'm not sure, but it's possible some version of unity would want that file to in this location instead, so you could try it:
    Assets/Plugins/Android/InternetReachabilityVerifier_NetworkSecurityConfig.aar
     
  13. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    94
    @tonic I've tried these.

    1. Can't update because of unstable unity release. At least for some SDKs.
    I removed #if #endif, to define IRV_USE_WEBREQUEST, but it didn't help.

    2. I doubled checked checkbox for InternetReachabilityVerifier_NetworkSecurityConfig.aar
    Also I tried to move it to "Assets/Plugins/Android/". It didn't help also. I have some other SDKs in the project and their plugins works good from separate folders (not the main "Plugins" folder).
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @Shefich I'll try to test with the same Unity version. But I'm starting to suspect this is an issue which only happens with certain Unity or Android SDK version, and if so, the only remedy may be to upgrade either one.
     
  15. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @Shefich, yes, just confirmed the cause is that Unity 2018.2.21f1 just doesn't recognize yet the Android 9 platform even if a capable SDK is installed.

    So you either have to upgrade to newer Unity version, or alternatively accept using the android:usesCleartextTraffic="true" workaround in manifest.

    Player Settings Android Target API level in Unity 2018.2.21f1:
    It doesn't let you pick higher than 8.1 'Oreo' (API level 27), so that's highest also for "Automatic".
    android_u2018221.png

    Player Settings Android Target API level in Unity 2018.3.0f2:
    Here Unity lets you pick Android 9.0 'Pie' (API level 28), required for the network security config to work.
    android_u201830.png
     
  16. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    94
    @tonic thank you for the confirmation.
     
  17. Jochanan

    Jochanan

    Joined:
    Nov 9, 2016
    Posts:
    85
    Hi @tonic
    Does your asset determines, when user switches from WiFi to Carrier Network internet on mobile phone?
    I would guess, that there is a time, when the device has no access to the internet, so it could be detected by that, but the timeframe without internet is not set. I do not want do do the test every Update to check it out. Is there a reliable way, hot to figure it out?

    Do i have to use https://docs.unity3d.com/ScriptReference/Application-internetReachability.html to check it? Is it compatible with your solution?

    We need to have a complex connection information because we are using 3rd party server side component, which is... very poorly designed to handle changes between network carrier and wifi internet connection.
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @Jochanan, thanks for the question.

    Internet Reachability Verifier (IRV) does not make a distinction between Carrier and WiFi/Local network. It uses Application.internetReachability to check when network is something else than "NotReachable" (after that passes, it makes a small actual network request to test if the result is what's expected).

    So, to answer your questions:

    Does your asset determines, when user switches from WiFi to Carrier Network internet on mobile phone?

    IRV asset does not determine switch between WiFi/Carrier Network.​

    I do not want do do the test every Update to check it out. Is there a reliable way, hot to figure it out?

    I do not know if there's better way with Unity API than to poll Application.internetReachability. You might be able to create platform-specific implementation to get a notification instead of polling, but that's out of scope for IRV asset.​

    Do i have to use https://docs.unity3d.com/ScriptReference/Application-internetReachability.html to check it? Is it compatible with your solution?

    IRV is asset is "compatible" with Application.internetReachability, and even uses it internally. But, IRV doesn't exactly help you any way to detect switch between WiFi/Carrier Network. Actually, it does not monitor "lost connectivity" at all -- that's an "error situation" you're supposed to detect with the networking API you're using for actual traffic, and whenever that happens, you can then ask IRV to verify the connectivity again (and wait for notification about that).
     
    Jochanan likes this.
  19. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Internet Reachability Verifier v1.2.2 has been released:

    Fixes for Unity 2019.3+ compatibility:
    • Verified support for Enter Play Mode without Domain/Scene Reload
    • Removed GUILayer components
     
  20. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
  21. pawandking25

    pawandking25

    Joined:
    Feb 11, 2020
    Posts:
    3
    @tonic hi I recently got the plugin. I am trying to integrate it into my game which is made in unity version 2018.2.15f1. the plugin seems to returning error on my andriod device and pending verification on my editior.
     
  22. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
  23. pawandking25

    pawandking25

    Joined:
    Feb 11, 2020
    Posts:
    3
    I was running the CustomIRVExample scene in 2018.4.18f1 and still does not run in andriod 10 and was running in andriod 8.
     
  24. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi, did you follow the specific instructions in this included PDF file: Instructions_InternetReachabilityVerifier.pdf
    More exactly, this section: 4.2 Using Custom Method on Android Platforms

    It's and advanced topic and has instructions how to set up an "cleartext" (http) exception for your own custom domain using Android Studio. Starting from Android 9 the operating system has stricter security controls, and requires this kind of specific network security config.

    Alternatively, if you are only doing networking against your own server, and your server supports https traffic, I'd recommend you simply use custom https url to a text file instead (txt file containing your own test text, and enter same content in unity to IRV component "custom method expected data").

    Note that the example CustomIRVExample.scene contains http test url against my company server. That's for simple testing inside editor. That url is not meant to be deployed in any production/release builds, so it is also not included in ready-made .aar file containing network security config, which is why it won't work in Android build if you happen to try to use it without a custom own domain and test file.
     
  25. pawandking25

    pawandking25

    Joined:
    Feb 11, 2020
    Posts:
    3
    @tonic The following images show you the :-
    unity version,
    scene,
    settings
    build results.
    andriod 8 it works perfect but on andriod 9 and above it doesnt
     

    Attached Files:

  26. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi @pawandking25, thanks for helpful screenshots.

    I just tried to do a fresh installation of the exact same Unity version, and fresh-imported IRV to a new blank project.

    When making an Android build, I'm unable to reproduce the issue, when running on Android 10.

    It's bit hard to guess what might be wrong. But could you check the following things next:
    • Use the Android development kit what is installed with Unity
    • In Build Settings for Android, use Target API level 28 (or larger)
    • Verify your Unity project has the following file, and that it's flagged to be included in the Android build:
      InternetReachabilityVerifier/Plugins/Android/InternetReachabilityVerifier_NetworkSecurityConfig.aar

     
  27. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    725
    Hi, description on Asset Store says that asset is actively developed, but last update was almost a year ago.
    Do you have any plans for new features like in Online Check PRO?
     
  28. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi @atorisa, thanks for the interest!

    By stating that the asset is actively updated, my intention is to signal that my asset has been the quickest to respond and do some necessary fixes for underlying platform changes.

    For example, the "Android 9 network security config". I believe some other assets of this category still have an update for that issue.

    My aim is to do the one thing well that the asset promises, and do it in minimal way that the asset itself is as simple and small as possible, with only a few files, so that's it's "drop in". So I'm not planning to keep adding features which would be only loosely connected.
     
  29. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    725
    Ok, can you make some test for me?

    I use the latest Unity Ads version. And as I understand the next situation describes why Unity Default Internet Checker is not reliable as docs says: https://docs.unity3d.com/ScriptReference/Application-internetReachability.html

    So there is a limitation for Unity Ads that it needs to be initialized when Internet is ON.

    When I test with Device Simulator package 2.2.3 (from UPM) in Unity Editor on macOS without Internet having internet on Device Simulator then I get: "Invalid configuration request for gameId". This is because simulator provides knowledge to Unity that Internet is ON, but is not in fact. So trouble is here.

    How your plugin will work in this case?
     
    Last edited: Aug 6, 2020
  30. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi, using my plugin always requires some small amount of integration (or "glue") code. You're responsible for making that code, as it's naturally always different case by case.

    In this case, your glue code should follow this kind of standard pattern, which is applicable to almost all situations:
    1. Initialize Internet Reachability Verifier, which will also start to test internet connection in the background.
    2. Wait for it to notify that internet connection works.
    3. Start your other networking tasks (in this case, you would now initialize Unity Ads).
    4. Check for error return codes from previous step. Also do same check for every subsequent networking operation. (How you do this depends on the system you're using, in this case you'd check the error code from Unity Ads what you have already done.)
    5. When you get an error code which suggests that internet connection has been cut, then you ask Internet Reachability Verifier to verify connection again, and go back to step 2.
    Support for this asset does not cover doing this kind of project-specific implementation for you.

    Please note that the step 4 above is very important. That's needed for optimal user experience, as then it will be known as soon as possible when networking operations fail, and reacted upon (by starting new check).

    Some other assets of this kind actively poll network constantly instead, but that basically (1) wastes network bandwidth, which often costs actual money for users, so it's impolite, and (2) leads to longer reaction time for lost network, as the loss is realized only after intermittent poll fails, not immediately when an error situation is hit.
     
  31. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    725
    Let's suppose that I want to change detection method from Custom to "Default by Platform" in realtime using Unity Remote Config. It is useful when having troubles with my own server, so I could remotely change it to avoid errors for most people.

    Is this possible? So there are functions to achieve it?
    And there is way to achieve it with self-control without Unity Remote Config? That is app must monitors are there errors with connections to my server or not... and switch the method automatically.
     
  32. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    I'm not familiar with Unity Remote Config, so I'm not entirely sure about this. But if it allows changing of some kind of custom value defined by yourself, then you a tiny amount of code will make it possible to change the behavior like you described. If it supports remote editing of custom enumerated values in game objects, then you might be able to setup that remote config even without needing glue code.

    Alternatively you could of course do some modifications to code of the IRV asset itself to use some other detection method as a fallback. Any own customizations are of course up to you to verify and maintain afterwards. But, that's actually a feature I might consider adding to the asset itself, although I can't give any timeline.
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Internet Reachability Verifier v1.2.3 has been released:
    • Fixes for Unity 2020.2+ compatibility
    • This is the last version to support legacy Unity versions from 3.5.7 to 5.6.6.
      (Likely support for Unity 5.6.7 will continue.)
     
    makaka-org likes this.
  34. makaka-org

    makaka-org

    Joined:
    Dec 1, 2013
    Posts:
    725
  35. unitphoenix

    unitphoenix

    Joined:
    Oct 29, 2021
    Posts:
    3
    Hello @tonic
    I've purchased this plugin but facing some issues for WebGL, macOS, and Windows platforms wherein callback is not coming in method (netStatusChanged in SkeletonIVR & IRV example ) when the internet connection is lost in between (not even in the editor), unlike for mobile platforms (callback is coming in iOS and Android). Could you please suggest if something is missed or an additional setting is required for the aforementioned platforms?

    Unity version used: 2020.3.19f1
    Plugin version: 1.2.3
     
  36. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi @unitphoenix,

    I'll quote two places from the included "Instructions" PDF document:

    1. Additional note from method void forceReverification() documentation:

    You should call this after your own networking calls start to return errors that indicate effective loss of network connectivity. The Internet Reachability Verifier will not actively monitor if effective networking will suddenly stop working at middle of some operation. However, it will change to offline status if user disables all networking (e.g. by activating airplane/flight mode).

    So, this tells you to always check the error values from whatever networking you're doing; and if that fails, you could then ask IRV to verify networking again (and wait until it says that it works).

    That also explains why mobile platforms work a bit differently. It is quite normal there that the "network interface" may completely disappear, and then come back. But on desktop platforms normally you don't lose all of the network interfaces even if one goes down.

    2. From the Questions and Answers section:

    If user was already verified to be online, why going offline is not detected?

    Note that “going offline” is detected when app user disables all networking (e.g. by activating airplane/flight mode). However, other than that, IRV will not actively monitor the current quality of internet connectivity. You’re supposed to add code to your own networking, which checks for error situations. For example, if network connection drops away right in middle of transferring data. After you detect such an error, you can always then ask IRV to verify the network connection again.

    Moreover, it’s important to note the difference in trying to connect when being offline (zero traffic until user is online), and monitoring connectivity when already online (requires constant traffic). Such constant “unnecessary” traffic would be impolite towards end-users, because in many places users still have to pay by amount of used traffic.​

    Hope this helps!
     
  37. unitphoenix

    unitphoenix

    Joined:
    Oct 29, 2021
    Posts:
    3
    @tonic Thanks for the suggestion, it helped. Although appears that in the macOS app and webGL, the plugin doesn't seem to auto-detect offline status when the internet is switched off (unless force verification is triggered) contrary to the expected behavior.
     
  38. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Glad to hear the suggestions helped!
    It's a design choice that all variants of "going offline" are not detected behind the scenes, even if some users expect that. The reasoning for this choice is explained in that Q&A section, bolded below:

    Note that “going offline” is detected when app user disables all networking (e.g. by activating airplane/flight mode). However, other than that, IRV will not actively monitor the current quality of internet connectivity. You’re supposed to add code to your own networking, which checks for error situations. For example, if network connection drops away right in middle of transferring data. After you detect such an error, you can always then ask IRV to verify the network connection again.​

    Moreover, it’s important to note the difference in trying to connect when being offline (zero traffic until user is online), and monitoring connectivity when already online (requires constant traffic). Such constant “unnecessary” traffic would be impolite towards end-users, because in many places users still have to pay by amount of used traffic.
    I've considered adding this feature of 'background monitoring' as optional toggle, and perhaps only for the custom method. But so far I've chosen not to do this, since I think it would be generally impolite towards the users to have that feature.
     
  39. unitphoenix

    unitphoenix

    Joined:
    Oct 29, 2021
    Posts:
    3
    got your point. I was just wondering why even disabling the network completely (from the source itself) didn't result in "going offline" (in regards to the quoted point: Note that “going offline” is detected when app user disables all networking (e.g. by activating airplane/flight mode).)
     
  40. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @unitphoenix ah, I see. It's because networking stack is always technically available on desktop, even if you couldn't reach anything else than local network. This is exposed differently on desktop than on mobile platforms by Unity's Application.internetReachability API, which is used by IRV asset in part to determine if it's worth even trying.
     
  41. udubaso

    udubaso

    Joined:
    Dec 30, 2014
    Posts:
    15
    Is it somehow possible for this asset to work without enabling insecure connections? upload_2022-4-9_15-36-51.png
     
  42. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    This depends on the detection method (there are a few to choose from) and platform. Some of the detection methods use HTTP and some HTTPS.

    Using "insecure" HTTP detection allows better detection of captive portals. In this case it is not actually "insecure" as it is only checked if the fetched data matches already known and expected data or not. On Android, this requires tweaking Network Security Config (ready-made changes are included for the built-in detection methods). On iOS, using this type now requires App Transport Security (ATS) exception that you can configure for the app (which may be rejected by Apple). There's more information is the included documentation.

    You can also pick a HTTPS detection method (and this is actually the default e.g. on Apple platforms now because of that uncertainty with ATS). This will also work well and there is no need to enable the "insecure" HTTP connections. The detection result will still tell if the small https test was successful or not.
    In that case, it is possible that HTTP requests might still go to a captive portal in the same network, but if all the traffic is https, there's no need to actually care about that.
     
  43. udubaso

    udubaso

    Joined:
    Dec 30, 2014
    Posts:
    15
    Well, I recommend setting a HTTPS method as the default on Android, too. Because when I launched "SkeletonIRVExample" scene on my Android phone, an error was thrown saying I had insecure connections disabled in the player settings. And no connection changes were detected, the state was always "pending". So for me to use this asset (I build my app for both Android and iOS) I need to either set manually detection methods for each platform, or enable insecure connections through player settings (which I don't want).
     
  44. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    @udubaso Thanks, that's a fair point, I will consider this for next version.
     
  45. yilianxin

    yilianxin

    Joined:
    Jan 22, 2015
    Posts:
    5
    "I want to purchase this plugin, but I have some questions about whether it can help me with issues I encountered. To put it simply, I have some VR devices that are connected to routers in different places. Sometimes, the internet connected to these routers can cause issues where there is WIFI but no internet. If I query a website via www or UnityWebRequest, the result returned will be the login page of the current router. I would like to know if IVR can help me address the following issues:

    1. Can I obtain the current network status - especially when the network changes from normal to no Internet status - by using IVR's internal methods, callbacks, update or coroutines?
    2. Can I customize some network or website URLs for IVR to check so that I can be alerted to the current network status?"
     
  46. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    427
    Hi @yilianxin, thank you for the interest. Here are comments on your questions:
    1. IRV does not actively monitor network status so that it would alert you to a suddenly failing network, after you have already verified the network connectivity. For this situation, the expectation and the "correct" way is that you have custom code that notices errors of any networking operations you are doing. When you get such error, then you can ask IRV simply to re-verify the internet connection again.

    2. IRV has built-in support for major captive portal detection urls, but you can also use a custom URL instead.