ReactiveNetwork icon indicating copy to clipboard operation
ReactiveNetwork copied to clipboard

Internet connectivity issue: Could not establish connection with WalledGardenStrategy

Open mirwisek opened this issue 3 years ago • 1 comments

Internet connected state is misleading I added the library to my projects and I'm only observing internet connectivity. It is always returning false even when my wifi is working fine. To confirm that, I observed network state and it is returning CONNECTED while internet connectivity is showing false.

To Reproduce Steps to reproduce the behavior:

  1. I just tested the Kotlin sample nothing fancy

Expected behavior It should show that internet is connected while Network state is CONNECTED

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone:

  • Device: Xaiomi Pocco F3
  • OS: Android 12
  • Library Version: v3.0.8-rx2

Error

I'm continuously getting the following error after each 2 seconds. It seems the library is pinging a URL that is http (Not permitted).

E/ReactiveNetwork: Could not establish connection with WalledGardenStrategy
    java.io.IOException: Cleartext HTTP traffic to clients3.google.com not permitted
        at com.android.okhttp.HttpHandler$CleartextURLFilter.checkURLPermitted(HttpHandler.java:127)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:462)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
        at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
        at com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy.isConnected(WalledGardenInternetObservingStrategy.java:109)
        at com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy$1.apply(WalledGardenInternetObservingStrategy.java:66)
        at com.github.pwittchen.reactivenetwork.library.rx2.internet.observing.strategy.WalledGardenInternetObservingStrategy$1.apply(WalledGardenInternetObservingStrategy.java:64)
        at io.reactivex.internal.operators.observable.ObservableMap$MapObserver.onNext(ObservableMap.java:57)
        at io.reactivex.internal.operators.observable.ObservableInterval$IntervalObserver.run(ObservableInterval.java:82)
        at io.reactivex.Scheduler$PeriodicDirectTask.run(Scheduler.java:532)
        at io.reactivex.Scheduler$Worker$PeriodicTask.run(Scheduler.java:479)
        at io.reactivex.internal.schedulers.ScheduledRunnable.run(ScheduledRunnable.java:66)
        at io.reactivex.internal.schedulers.ScheduledRunnable.call(ScheduledRunnable.java:57)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:920)

mirwisek avatar Aug 10 '22 07:08 mirwisek

Thanks for reporting this issue. It looks like clear text traffic configuration is missing. Please, have a look at this paragraph: https://github.com/pwittchen/ReactiveNetwork#cleartext-traffic . Moreover, if you want to use WalledGardenInternetObservingStrategy, please update HTTP response code via InternetObservingSettings. E.g set it to 200 because default is 204. You can also try to set different custom host for checking connectivity via InternetObsevingSettings if clients3.google.com does not work in your country.

All of that is described in details in documentation in README.md.

Regards, Piotr

pwittchen avatar Aug 10 '22 09:08 pwittchen