Forum Xamarin.Forms
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

How to measure internet latency?

With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

Is there any alternative to know that?

Best Answer

Answers

  • JarvanJarvan Member, Xamarin Team Xamurai
    edited December 2019

    IsReachable is not implemented in Xamarin.Essentials as each device handles this very different and was never 100% reliable. That will actually slow your app down by pinging and then making the request. See the link.

    I cannot measure or know if a web page is available

    To check if an end point is available, try to use Xam.Plugin.Connectivity plugin.

    var connectivity = CrossConnectivity.Current;
    if(!connectivity.IsConnected)
          return false;
    
    var reachable = await connectivity.IsRemoteReachable("host");
    

    Tutorial: https://jamesmontemagno.github.io/ConnectivityPlugin/PingaHost.html

  • HectorOrmeoHectorOrmeo USMember ✭✭

    @Jarvan said:
    IsReachable is not implemented in Xamarin.Essentials as each device handles this very different and was never 100% reliable. That will actually slow your app down by pinging and then making the request. See the [link]

    I cannot measure or know if a web page is available

    To check if an end point is available, try to use [Xam.Plugin.Connectivity]
    ```
    var connectivity = CrossConnectivity.Current;
    if(!connectivity.IsConnected)
    return false;

    var reachable = await connectivity.IsRemoteReachable("host");

    The cross connectivity method did not work :(.

    Is there a way to measure latency?

  • JohnHardmanJohnHardman GBUniversity admin
    edited December 2019

    @HectorOrmeo said:

    With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

    Is there any alternative to know that?

    Just to clarify - do you want to:
    (a) know if a remote address is reachable (if so, does reachable mean that you can make a TCP connection to it, or is ICMP enough?)
    or
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

  • HectorOrmeoHectorOrmeo USMember ✭✭

    @JohnHardman said:

    @HectorOrmeo said:

    With xamarin essential (IsRemoteReachable) I cannot measure or know if a web page is available

    Is there any alternative to know that?

    Just to clarify - do you want to:
    (a) know if a remote address is reachable (if so, does reachable mean that you can make a TCP connection to it, or is ICMP enough?)
    or
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    Hi, I need to measure latency, a round trip

  • JohnHardmanJohnHardman GBUniversity admin
    edited December 2019

    @JohnHardman said:
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    At what level in the network stack?
    What are you trying to achieve? (what's the use case / user requirement?)

  • HectorOrmeoHectorOrmeo USMember ✭✭
    edited December 2019

    @JohnHardman said:

    @JohnHardman said:
    (b) measure latency? If latency, at what level in the network stack do you want to measure it? Will a round-trip time do? Given the variability when it comes to mobile devices, it would be useful to know what you are trying to achieve.

    At what level in the network stack?
    What are you trying to achieve? (what's the use case / user requirement?)

    I need to know if the connection is optimal to send information to the rest service and wait for an answer!> @JohnHardman

    example: send pictures

  • LuisDavidDelaCruzLuisDavidDelaCruz Member ✭✭✭

    Hi @HectorOrmeo , check out this solution
    The code returns the intensity of your wifi network

    Post
    https://luisdavidxamshap.wordpress.com/2019/05/09/intensidad-dewi-fi-xamarin-forms-version-android/

    In the case of iOS, it needs more permissions, I don't have it

    Check out the solution for Android

  • JohnHardmanJohnHardman GBUniversity admin

    @LuisDavidDelaCruz

    It's unclear (IMHO) what the original poster really needs (latency, round-trip time, whether a web page can be retrieved etc are not the same thing). I don't think that WiFi strength is what the original poster is asking for though.

    WiFi strength could be potentially useful for other things though, so it's a pity that it seems the API is not permitted to be used in apps in the iOS app store.

Sign In or Register to comment.