Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12035

[cordova-plugin-network-information] connection info is not reliable on Android 6

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.0
    • Fix Version/s: None
    • Labels:
    • Environment:

      Description

      I've noticed that information exposed by the plugin is not reliable. It happens often that I'm connected to the internet via WiFi, and the plugin says that there's no connection.

      It's not easy to reproduce it on-demand, but I reproduced it many times recently. It happens most often when in the morning, I open the Cordova app that was running in background throughout the night.

      Then, when I connect to Chrome Dev Tools, I can do a repl session like this:

      > navigator.connection.type
      "none"
      > window.fetch('http://www.example.org').then(function(res) {console.log(res.status)})
      Promise {[[PromiseStatus]]: "pending", [[PromiseValue]]: undefined}
      200
      Fetch complete: GET "http://www.example.org/".(anonymous function)
      > navigator.connection.type
      "none"
      

      So, the plugin thinks I'm offline, yet any HTTP calls done within the app without checking if I'm offline or online, are successful (either from the app or devtools).

      When I disable WiFi and reenable it, after a few seconds the plugin updates its state and then it tells that connection type is "wifi".

      There are several possibilities here:

      • either system (or device driver) gives us incorrect information, or
      • cordova plugin is caching data and/or not listening properly to all the events and/or incorrectly processing it

      and most probably the issue manifests itself when the device is asleep for many hours (but I'm not sure about this).

      Note that I also noticed another issue, that sometimes the Chrome network stack thinks I'm offline (when I do an HTTP call, it fails immediately and I see network errors in devtools console) - and then I restart the Cordova app, and everything's fine, all HTTP calls are ok - but this is unrelated to this ticket, and perhaps a bug in Chrome.

      This ticket seems to be most likely a bug in the plugin, because as I said before, doing HTTP call succeeds despite the plugin telling me that I'm offline.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jakub-g jakub-g
              • Votes:
                8 Vote for this issue
                Watchers:
                13 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 10m
                  10m