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.

WiFi reconnection not recognized when App is inactive

See original GitHub issue

Environment

System: OS: macOS Mojave 10.14.6 CPU: (4) x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Memory: 550.87 MB / 16.00 GB Shell: 3.2.57 - /bin/bash Binaries: Node: 11.14.0 - /usr/local/bin/node npm: 6.9.0 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 IDEs: Android Studio: 3.4 AI-183.5429.30.34.5452501 Xcode: 11.2/11B52 - /usr/bin/xcodebuild npmPackages: @react-native-community/cli: 2.9.0 => 2.9.0 react: 16.9.0 => 16.9.0 react-native: 0.61.2 => 0.61.2 npmGlobalPackages: react-native-cli: 2.0.1

Platforms

The issue only happens on iOS, everything works as expected on Android.

Versions

  • Android: N/A
  • iOS: 13.1.2
  • react-native-netinfo: 4.6.0
  • react-native: 0.61.2
  • react: 16.9.0

Description

Im using the following code to display a message when the user is offline:

<NetworkProvider>
    <NetworkConsumer>
               {({ isConnected }) =>
                        isConnected ? null : (
                            <View style={pageStyles.container}>
                                <Text style={pageStyles.text}>{t('app.offline')}</Text>
                            </View>
                        )
                }
    </NetworkConsumer>
</NetworkProvider>

When I turn of WiFi the mesage shows as expected. Also the message disappears as expected if I turn WiFi back on provided the App is open while the connection is created. However should the control center be open while the WiFi connection changes from disconnected to connected, (e.g. open control center, enable WiFi, wait for connection, close control center) then the message stating the user is offline will not disappear. The same thing happens, if I disable WiFi while in the App, then let the App go to the background, enable WiFi again and wait for it to connect. Getting the App back out from the background later, it still shows the offline message and the message also doesn’t go away with time.

I also found the following odd behaviour: When I am online and have an offline message that does not disappear on screen 1 and I navigate to another screen (screen 2) that would also render an offline message if I would be offline, this screen does not show an offline message (as it should be). Navigating back to screen 1 I will see the offline message again (not as it should be) even though screen 2 obviously realized that the user is online.

Also I’m testing on a real iOS device not on a Simulator.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:9

github_iconTop GitHub Comments

3reactions
vrazncommented, Feb 6, 2020

@matt-oakes I think I have a similar problem. Sometimes, when the app is in the foreground and I lock the screen of an iPhone for 10-30 seconds (try with different time ranges) and unlock it later, the app states that it has no internet connection.

I’ve created a minimal reproducible demo, you can grab it from here

Once the bug appears - even if you add a button to perform a forced connection check - this will give no result, as the library will continue to return { isInternetReachable: false } for some time, even though it’s not true. The issue goes away automatically after a minute or so, or after restarting the WiFi through ios control center (the app should be in the foreground).

Android version seems to work fine.

1reaction
SAHITYASAIcommented, Mar 17, 2020

@matt-oakes I think I have a similar problem. Sometimes, when the app is in the foreground and I lock the screen of an iPhone for 10-30 seconds (try with different time ranges) and unlock it later, the app states that it has no internet connection.

I’ve created a minimal reproducible demo, you can grab it from here

Once the bug appears - even if you add a button to perform a forced connection check - this will give no result, as the library will continue to return { isInternetReachable: false } for some time, even though it’s not true. The issue goes away automatically after a minute or so, or after restarting the WiFi through ios control center (the app should be in the foreground).

Android version seems to work fine.

Facing the same issue on iOS. Tried re-fetching the network status whenever app state changes using AppState and still issue is not gone. Did u succeed in finding any solution?

Read more comments on GitHub >

github_iconTop Results From Across the Web

WiFi reconnection not recognized when App is inactive #248
The same thing happens, if I disable WiFi while in the App, then let the App go to the background, enable WiFi again...
Read more >
If your iPhone or iPad won't connect to a Wi-Fi network
If you see Auto Join disabled under Settings > Wi-Fi > [Your Network], tap the More Info button and then tap Auto-Join.
Read more >
Troubleshooting Wi-Fi connection on your Surface
Your Surface shows that it's connected to your wireless network but it's not working or “limited” may appear under your Wi-Fi network name...
Read more >
How To Fix WiFi Not Working Issue On Windows 10 - YouTube
In this video, you will see the ways to fix the No wifi issue with windows 10. Wifi not working to not connecting...
Read more >
Android : Reconnect to Wi-Fi after entering coverage area ...
Result : The Wifi is not reconnected immediately and thus app does not reconnect to server. Depending on the device and settings, sometimes...
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