Code Monkey home page Code Monkey logo

Comments (29)

alvesluc avatar alvesluc commented on July 1, 2024 5

My app isn't been accepted in Apple's store because it always says that there's no internet connection...

from data_connection_checker.

dungnv2602 avatar dungnv2602 commented on July 1, 2024 5

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.

red42 avatar red42 commented on July 1, 2024 4

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.

fpv999 avatar fpv999 commented on July 1, 2024 3

that's bad. Local DNS resolving can work on cached addresses sometimes.

from data_connection_checker.

fpv999 avatar fpv999 commented on July 1, 2024 2

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.

fpv999 avatar fpv999 commented on July 1, 2024 2

but DNS addresses can be cached in local DNS servers.

from data_connection_checker.

vytautas-pranskunas- avatar vytautas-pranskunas- commented on July 1, 2024 2

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.

mrverdant13 avatar mrverdant13 commented on July 1, 2024 1

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.

d-apps avatar d-apps commented on July 1, 2024 1

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;

}

Source: https://stackoverflow.com/questions/49648022/check-whether-there-is-an-internet-connection-available-on-flutter-app

from data_connection_checker.

FlorianBouron avatar FlorianBouron commented on July 1, 2024

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.

voivoed avatar voivoed commented on July 1, 2024

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.

alvesluc avatar alvesluc commented on July 1, 2024

from data_connection_checker.

mixemer avatar mixemer commented on July 1, 2024

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.

spiderion avatar spiderion commented on July 1, 2024

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.

mrverdant13 avatar mrverdant13 commented on July 1, 2024

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.

jans-y avatar jans-y commented on July 1, 2024

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.

fpv999 avatar fpv999 commented on July 1, 2024

because Apple is testing apps in IPv6 network!

from data_connection_checker.

Mosamisa avatar Mosamisa commented on July 1, 2024

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.

fpv999 avatar fpv999 commented on July 1, 2024

https://medium.com/@mhalitk/test-ipv6-compatibility-of-ios-application-360d6a33bd23

from data_connection_checker.

GyuriMajercsik avatar GyuriMajercsik commented on July 1, 2024

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.

boskokg avatar boskokg commented on July 1, 2024

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.

diegopq avatar diegopq commented on July 1, 2024

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.

prasantco avatar prasantco commented on July 1, 2024

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.

dokinkon avatar dokinkon commented on July 1, 2024

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.

quentinleguennec avatar quentinleguennec commented on July 1, 2024

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

from data_connection_checker.

ahshingx95 avatar ahshingx95 commented on July 1, 2024

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.

red42 avatar red42 commented on July 1, 2024

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.

miguelflores1993 avatar miguelflores1993 commented on July 1, 2024

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.

RounakTadvi avatar RounakTadvi commented on July 1, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.