data_connection_checker
data_connection_checker copied to clipboard
No internet connection even though I have internet connection.
flutter: No internet :( Reason: flutter: [AddressCheckResult(AddressCheckOptions(InternetAddress('1.1.1.1', IPv4), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('8.8.4.4', IPv4), 53, 0:00:10.000000), false), AddressCheckResult(AddressCheckOptions(InternetAddress('208.67.222.222', IPv4), 53, 0:00:10.000000), false)]
I am using a school wifi connection and data_connection_checker is failing when tries to connect internet. I tried a different wifi (my phone's), it worked.
I am hoping this can be fixed because the app I am developing is focusing on students and they will be at school most of the time :)
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?
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.
My app isn't been accepted in Apple's store because it always says that there's no internet connection...
I can confirm that DataConnectionChecker().hasConnection return false when running in release mode, but run normally in debug mode. Weird behavior.
So, there's no way to solve this?
On Sun, Feb 9, 2020, 18:18 Nguyễn Việt Dũng [email protected] wrote:
I can confirm that DataConnectionChecker().hasConnection return false when running in release mode, but run normally in debug mode. Weird behavior.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/komapeb/data_connection_checker/issues/6?email_source=notifications&email_token=AKGWGBM5ASAUKSJLGPQX7C3RCBXLHA5CNFSM4KHYU7UKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELGYM2I#issuecomment-583894633, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKGWGBP3PI2BGDVCDBHIO7TRCBXLHANCNFSM4KHYU7UA .
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.
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
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. 🤔
Same problem here. App Store rejected my build.
I think I have used v1.13.6-beta or v1.14.6-beta.
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.
because Apple is testing apps in IPv6 network!
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 ;-)
because Apple is testing apps in IPv6 network!
Do you know a way to test apps in an ipv6 environment /network?
https://medium.com/@mhalitk/test-ipv6-compatibility-of-ios-application-360d6a33bd23
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)
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
but DNS addresses can be cached in local DNS servers.
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
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.
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.
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.
https://stackoverflow.com/questions/49648022/check-whether-there-is-an-internet-connection-available-on-flutter-app/62537696#62537696
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'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 = ??
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.
replace this code with the old one:
static final List<AddressCheckOptions> 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, ), ]);
I had the same issue and this code solved, I am not using this package anymore,
static Future
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;
}
Source: https://stackoverflow.com/questions/49648022/check-whether-there-is-an-internet-connection-available-on-flutter-app
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();
}
that's bad. Local DNS resolving can work on cached addresses sometimes.
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?