getInternetConnectionProfile is not async and can block the application RRS feed

  • Question

  • ...if the connection is currently changing. Before we operate with WinJS.xhr we test the internet connection using:

    hasInternetConnection = function() {
        var level, profile;
        profile = Connectivity.NetworkInformation.getInternetConnectionProfile();
        level = profile != null ? profile.getNetworkConnectivityLevel() : void 0;
        return level === Connectivity.NetworkConnectivityLevel.internetAccess;

    However, if the connection is currently being disabled (by pulling the cable or other means like router reset etc) the call to getInternetConnectionProfile() blocks the whole app.

    Whats the recommended way to handle connection changes? Listening to network change events does not seem to help as also then the getInternetConnectionProfile call would block.

    Wednesday, March 13, 2013 3:55 PM

All replies

  • How can you confirm that the call "hangs"? Here is what I have done to try to reproduce the issue:

    1.) Run the "Network Information Sample"

    2.) Run Scenario 1, "Get Internet connection..." and put a breakpoint in the function displayInternetConnectionProfileInfo in internet-connection-profile.js right before the networkInfo.getInternetConnectionProfile function is called.

    3.) Disconnect the network cable

    4.) Step over the breakpoint.

    5.) The internetProfile object is returned immediately to be null, so there is no hang.



    Thursday, March 14, 2013 1:36 AM
  • I can reproduce this every time on my machine and the profiler spits out that 98% of the hotpath is spent in said function.

    It seems to be a timeout issue, that also occurs when a XHR request is currently performed and I pull the cable. The loss of connection is not recognized immediately.

    Thursday, March 14, 2013 10:04 AM
  • Hi Phil,

    Please post explicit repro steps.



    Jeff Sanders (MSFT)

    Thursday, March 14, 2013 10:51 AM