question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Android 10 - type is `none` for no internet wifi connections.

See original GitHub issue

Environment

System: OS: macOS 10.15.4 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Memory: 391.18 MB / 16.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node Yarn: 1.22.5 - /usr/local/bin/yarn npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 14.0, DriverKit 19.0, macOS 10.15, tvOS 14.0, watchOS 7.0 Android SDK: API Levels: 23, 25, 26, 27, 28, 29 Build Tools: 27.0.3, 28.0.3, 29.0.2, 29.0.3 System Images: android-19 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.0/12A7209 - /usr/bin/xcodebuild npmPackages: react: 16.8.6 => 16.8.6 react-native: 0.60.0 => 0.60.0 npmGlobalPackages: react-native-cli: 2.0.1 react-native-rename: 2.4.1

Platforms

Android

Versions

Description

Not sure if this bug belongs here. Don’t think it is a regression.

On Android 10 and Android 11, when connecting to a WIFI network that doesn’t have internet access, and the connection is performed through the OS WIFI settings, the netInfo object correctly shows the type as wifi, and the network details.

Screen Shot 2020-09-23 at 00 19 43

When connecting to the same WIFI network, and the connection is performed through the WifiManager.connectToProtectedSSID function from the react-native-wifi-reborn library (and the connection succeeds), the type in the netInfo object is always none and the connection details are empty.

Screen Shot 2020-09-22 at 23 45 35

Devices reflect being connected to the WIFI network, both on the control panel and the WIFI settings.

Not sure where this bug belongs.

  • Experiencing this on several Android 10 and Android 11 devices.
  • Having the same behavior with the useNetInfo hook, as well as when adding listeners manually.

Reproducible Demo

import React, { useEffect } from 'react';
import { useNetInfo } from '@react-native-community/netinfo';
import WifiManager from 'react-native-wifi-reborn';

const SomeComponent = () => {
    const netInfo = useNetInfo();

    ...

    useEffect(() => {
        console.log(netInfo);
        // netInfo object never reflects being connected to the wifi that has no internet access.
        // Instead, it shows:
        // {
        //     details: {}
        //     isConnected: false
        //     isInternetReachable: false
        //     isWifiEnabled: true
        //     type: "none"
        // }
    }, [netInfo]);
    
    useEffect(() => {
        WifiManager.connectToProtectedSSID('network-without-internet-access', '', false);
    }, []);

    ...

}

Please let me know if there’s more information I can provide.

Thanks!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
Rapsssitocommented, Oct 16, 2020

@pherrera91, when connecting to a new WiFi network, make sure to wait a little so all changes can be fetched correctly. You might also be getting a cached network information. If you just want to fetch the WiFi status and avoid any caching, you may call NetInfo.fetch("wifi").

2reactions
pherrera91commented, Sep 24, 2020

Did a little bit more digging into the issue.

This is not true.

When connecting to the same WIFI network, and the connection is performed through the WifiManager.connectToProtectedSSID function from the react-native-wifi-reborn library (and the connection succeeds), the type in the netInfo object is always none and the connection details are empty.

It seems the issue is not that none is returned. none being returned is okay, because that’s the state prior to being connected to a network. The problem is that the library is not detecting the connection to the new wifi network that has no internet, and no new data is returned.

I did some debugging and I ended up finding out that onAvailable (inside ConnectivityManager.NetworkCallback -> NetworkCallbackConnectivityReceiver.java) is never called for the network I’m connecting to.

I’m still looking at it, to see if I find something else.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android 10 - type is none for no internet wifi connections. #411
It seems the issue is not that none is returned. none being returned is okay, because that's the state prior to being connected...
Read more >
How to Fix Android WiFi is Connected But No Internet? - iMobie
1. Issues with the Router. A common reason why your phone has a WiFi connection but no Internet access is that there is...
Read more >
How to Fix "Wifi Has No Internet Access Android Issue"
Another simple solution to fix Android connected to wi-fi without Internet connectivity is to check whether the mobile data is off. It is...
Read more >
How to Fix Android Connected To WiFi But No Internet
1. Check If You Are Actually Connected to the Internet · 2. Check If Mobile Data is Turned Off · 3. Check for...
Read more >
Android Connected to Wi-Fi but No Internet? 11 Fixes to Try
This is another effective troubleshooting technique worth trying. Go to Settings > Network & Internet > Wi-Fi and long-press the Wi-Fi ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found