Search Unity

  1. Click here to see what's on sale for the "Best of Super Sale" on the Asset Store
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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:
    402
    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:
    4
    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:
    402
    @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:
    402
    @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:
    4
    Thank you that fix worked! Much appreciated.
     
  6. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    402
    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:
    402
    Hi @NandhuVicky, thanks for the question. There's no any kind of speed monitoring involved.
     
  9. Shefich

    Shefich

    Joined:
    May 23, 2013
    Posts:
    29
    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:
    402
    @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:
    29
    @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:
    402
    @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:
    29
    @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:
    402
    @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:
    402
    @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:
    29
    @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:
    402
    @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:
    402
    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:
    402
  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:
    402
  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:
    402
    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:
    402
    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:
    360
    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:
    402
    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:
    360
    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:
    402
    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:
    360
    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:
    402
    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:
    402
    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.)
     
unityunity