Comments (29)
My app isn't been accepted in Apple's store because it always says that there's no internet connection...
from data_connection_checker.
I can confirm that DataConnectionChecker().hasConnection return false when running in release mode, but run normally in debug mode. Weird behavior.
from data_connection_checker.
I've added the IPv6 DNS addresses for Google, CloudFlare and OpenDNS and it seems to have solved the problem on IPv6-only networks. Similar to @quentinleguennec 's answer above, but still using data_connection_checker
.
List<AddressCheckOptions> addresses = List.from(DataConnectionChecker.DEFAULT_ADDRESSES);
addresses.addAll([
AddressCheckOptions(
InternetAddress('2001:4860:4860::8888', type: InternetAddressType.IPv6), // Google
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('2001:4860:4860::8844', type: InternetAddressType.IPv6), // Google
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('2606:4700:4700::64', type: InternetAddressType.IPv6), // CloudFlare
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('2606:4700:4700::6400', type: InternetAddressType.IPv6), // CloudFlare
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('2620:119:35::35', type: InternetAddressType.IPv6), // OpenDNS
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('2620:119:53::53', type: InternetAddressType.IPv6), // OpenDNS
port: DataConnectionChecker.DEFAULT_PORT,
timeout: DataConnectionChecker.DEFAULT_TIMEOUT,
),
]);
DataConnectionChecker().addresses = addresses;
DataConnectionChecker().onStatusChange.listen((status) {
// your usual code here
});
from data_connection_checker.
that's bad. Local DNS resolving can work on cached addresses sometimes.
from data_connection_checker.
I just solved it by adding the internet permission (
<uses-permission android:name="android.permission.INTERNET" />
) to the AndroidManifest (all of them).
Hope it helps, guys.
Adding Android permission to iOS app won't solve things ;-)
from data_connection_checker.
but DNS addresses can be cached in local DNS servers.
from data_connection_checker.
i somebody i slooking for similar implemetation without this module here is the code:
import 'dart:io';
class InternetConnetionCheckerService {
get hasConnection async {
bool result;
try {
final list = await InternetAddress.lookup('google.com');
if (list.isNotEmpty && list[0].rawAddress.isNotEmpty) {
result = true;
}
} on SocketException catch (_) {
result = false;
return result;
}
return result;
}
Stream<bool> get onStatusChange =>
Stream.periodic(Duration(seconds: 10)).asyncMap<bool>((c) async {
return await hasConnection;
}).distinct();
}
from data_connection_checker.
I just solved it by adding the internet permission (<uses-permission android:name="android.permission.INTERNET" />
) to the AndroidManifest (all of them).
Hope it helps, guys.
from data_connection_checker.
I had the same issue and this code solved, I am not using this package anymore,
static Future isInternetAvailable() async {
bool result;
try {
final list = await InternetAddress.lookup('google.com');
if (list.isNotEmpty && list[0].rawAddress.isNotEmpty) {
result = true;
print('CONNECTED!');
}
} on SocketException catch (_) {
print('NOT CONNECTED!');
result = false;
return result;
}
return result;
}
from data_connection_checker.
Did you have an internet connection at the moment? Maybe you were on the network but the internet connection was not working.
Have you also try to ping manually the different IPs from the documentation?
from data_connection_checker.
I just updated to the last version of Flutter and this library has stopped working for me too. I have an internet connection, can ping the IPs from the documentation fine, but DataConnectionChecker().hasConnection sits there for several seconds and then returns false.
from data_connection_checker.
from data_connection_checker.
Have you also try to ping manually the different IPs from the documentation?
Yes I had internet connection. It was working. I did not try to change IPs. However I used connectivity library and this library together. It works for now.
from data_connection_checker.
My app isn't been accepted in Apple's store because it always says that there's no internet connection...
I have the same problem
from data_connection_checker.
I can confirm that DataConnectionChecker().hasConnection return false when running in release mode, but run normally in debug mode. Weird behavior.
I am having the same issue. It all works fine on debug mode, but seems to always return false on release mode. 🤔
from data_connection_checker.
Same problem here. App Store rejected my build.
I think I have used v1.13.6-beta or v1.14.6-beta.
from data_connection_checker.
because Apple is testing apps in IPv6 network!
from data_connection_checker.
because Apple is testing apps in IPv6 network!
Do you know a way to test apps in an ipv6 environment /network?
from data_connection_checker.
https://medium.com/@mhalitk/test-ipv6-compatibility-of-ios-application-360d6a33bd23
from data_connection_checker.
This happens for me as well. I got rejected two times because of this and didn't know why because in my tests everything worked fine.
(anyway, this plugin is really great and thanks for contributors)
from data_connection_checker.
What is wrong with the small part of code... why do you need plugin at all?
static final Duration _CONNECTIVITY_TIMEOUT = Duration(seconds: 1);
static Future _checkConnectivity() async {
try {
final result = await InternetAddress.lookup('google.com').timeout(_CONNECTIVITY_TIMEOUT);
if (result != null && result.isNotEmpty && result.first?.rawAddress?.isNotEmpty == true) {
return true;
}
} catch (e) {
print(e);
}
return false;
}
from data_connection_checker.
when the apk is generated and wifi is used it works well but when it is passed to the connection by mobile data it does not work. It does not seem to detect the change to mobile data. In debug mode it works well choose to use the following code final List<InternetAddress> res = await InternetAddress.lookup('google.com').timeout( Duration(seconds: 5), );
I saw it here:
https://stackoverflow.com/questions/49648022/check-whether-there-is-an-internet-connection-available-on-flutter-app
from data_connection_checker.
I'm also facing this issue. When i changed default timeout for WIFI to less than or equal to 1 seconds it will not take too time and working fine but when i test with same configuration on mobile it return internet connection not available.
from data_connection_checker.
I can confirm that DataConnectionChecker().hasConnection return false when running in release mode, but run normally in debug mode. Weird behavior.
Did you double check the AndroidManifest.xml contains following declaration?
<uses-permission android:name="android.permission.INTERNET"/>
Android Studio will add such use-permission in debug mode automatically. However you should add it manually in release mode.
from data_connection_checker.
I have implemented a solution taking inspiration from this plugin, I posted it on StackOverflow (so that people can try it and hopefully provide feedbacks). It seems to work fine but I would be really interested in feedbacks, I want to push it to prod at some point and testing network exceptions like these is really hard to do on your own.
from data_connection_checker.
I've added the IPv6 DNS addresses for Google, CloudFlare and OpenDNS and it seems to have solved the problem on IPv6-only networks. Similar to @quentinleguennec 's answer above, but still using
data_connection_checker
.List<AddressCheckOptions> addresses = List.from(DataConnectionChecker.DEFAULT_ADDRESSES); addresses.addAll([ AddressCheckOptions( InternetAddress('2001:4860:4860::8888', type: InternetAddressType.IPv6), // Google port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2001:4860:4860::8844', type: InternetAddressType.IPv6), // Google port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2606:4700:4700::64', type: InternetAddressType.IPv6), // CloudFlare port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2606:4700:4700::6400', type: InternetAddressType.IPv6), // CloudFlare port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2620:119:35::35', type: InternetAddressType.IPv6), // OpenDNS port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2620:119:53::53', type: InternetAddressType.IPv6), // OpenDNS port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), ]); DataConnectionChecker().addresses = addresses; DataConnectionChecker().onStatusChange.listen((status) { // your usual code here });
I'm having false results when using your ipv6 addresses, do you know what is wrong? please advice
This is the result:
[AddressCheckResult(AddressCheckOptions(InternetAddress('1.1.1.1', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('8.8.4.4', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('208.67.222.222', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('2001:4860:4860::8888', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2001:4860:4860::8844', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2606:4700:4700::64', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2606:4700:4700::6400', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2620:119:35::35', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2620:119:53::53', IPv6), 53, 0:00:10.000000), false)]
Edit:
I'm using Android, seems like using Wi-Fi cannot ping ipv6, when using data ipv6 returns true. But since IOS can only use ipv6 for production, if IOS device connected to Wi-Fi, can it ping and return true?
Case:
Android:
- Wifi, ipv4 = true, ipv6 = false
- Data, ipv4 = true, ipv6 = true
IOS: - Wifi, ipv4 = ??, ipv6 = ??
- Data, ipv4 = ??, ipv6 = ??
from data_connection_checker.
It shouldn't matter whether you are on wifi or mobile data. Can you confirm your Android on wifi has an ipv6 ip address? Your result suggests that wifi is ipv4 only.
from data_connection_checker.
replace this code with the old one:
static final List DEFAULT_ADDRESSES = List.unmodifiable([
AddressCheckOptions(
InternetAddress('1.0.0.1'),
port: DEFAULT_PORT,
timeout: DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('8.8.4.4'),
port: DEFAULT_PORT,
timeout: DEFAULT_TIMEOUT,
),
AddressCheckOptions(
InternetAddress('208.69.38.205'),
port: 80,
timeout: DEFAULT_TIMEOUT,
),
]);
from data_connection_checker.
I've added the IPv6 DNS addresses for Google, CloudFlare and OpenDNS and it seems to have solved the problem on IPv6-only networks. Similar to @quentinleguennec 's answer above, but still using
data_connection_checker
.List<AddressCheckOptions> addresses = List.from(DataConnectionChecker.DEFAULT_ADDRESSES); addresses.addAll([ AddressCheckOptions( InternetAddress('2001:4860:4860::8888', type: InternetAddressType.IPv6), // Google port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2001:4860:4860::8844', type: InternetAddressType.IPv6), // Google port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2606:4700:4700::64', type: InternetAddressType.IPv6), // CloudFlare port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2606:4700:4700::6400', type: InternetAddressType.IPv6), // CloudFlare port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2620:119:35::35', type: InternetAddressType.IPv6), // OpenDNS port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), AddressCheckOptions( InternetAddress('2620:119:53::53', type: InternetAddressType.IPv6), // OpenDNS port: DataConnectionChecker.DEFAULT_PORT, timeout: DataConnectionChecker.DEFAULT_TIMEOUT, ), ]); DataConnectionChecker().addresses = addresses; DataConnectionChecker().onStatusChange.listen((status) { // your usual code here });I'm having false results when using your ipv6 addresses, do you know what is wrong? please advice
This is the result:
[AddressCheckResult(AddressCheckOptions(InternetAddress('1.1.1.1', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('8.8.4.4', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('208.67.222.222', IPv4), 53, 0:00:10.000000), true), AddressCheckResult(AddressCheckOptions(InternetAddress('2001:4860:4860::8888', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2001:4860:4860::8844', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2606:4700:4700::64', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2606:4700:4700::6400', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2620:119:35::35', IPv6), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('2620:119:53::53', IPv6), 53, 0:00:10.000000), false)]
Edit:
I'm using Android, seems like using Wi-Fi cannot ping ipv6, when using data ipv6 returns true. But since IOS can only use ipv6 for production, if IOS device connected to Wi-Fi, can it ping and return true?Case:
Android:
- Wifi, ipv4 = true, ipv6 = false
- Data, ipv4 = true, ipv6 = true
IOS:- Wifi, ipv4 = ??, ipv6 = ??
- Data, ipv4 = ??, ipv6 = ??
Are you using port 443?
from data_connection_checker.
Related Issues (19)
- web support HOT 1
- It's still returning true even if my wifi has not active internet connection.. HOT 1
- Add network check
- SocketException connecting to https//1.1.1.1
- Don't use it on production for iOS! HOT 8
- Disconnected status when the application is in the background HOT 5
- Shows connection when there is not connection HOT 2
- Adding custom addresses to check for connection HOT 2
- SocketException when device is offline
- Insecure connections are disabled by default on iOS and Android
- Apple rejected my update due to data connection checker HOT 2
- Don't have internet connection appears while I have internet connection on sim 4g. HOT 3
- Migrate to Sound Null Safety HOT 9
- Null-safety HOT 8
- Modify testing logic to immediately return if any of the simultaneous pings succeed HOT 1
- Is this plugin still on BETA? HOT 1
- add stream of status for different addresses
- can't add the package (Version Failure) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from data_connection_checker.