New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Connectivity return incorrect results ? #230
Comments
Thanks for reporting this issue. This issue may be related to proxy or emulator configuration. I've tested it on real devices with a regular network connection and it worked fine. We can investigate proxy and emulator issue, but it may be system related thing. |
it happens on this real device : OS: Android 5.0 |
I've analyzed your code once again. Please note, you're using NetworkInfo#isAvailable() method. According to the documentation it "Indicates whether network connectivity is possible". Connectivity is possible, so the value is |
And this lib so cool. |
Ok. When everything is clear, then we can close this issue :). |
Im sorry for reopening this issue but i have a question that is similar to it. Please check the code below and i struggle with it because of the incorrect value it returns. Because i do have internet connection and the library return false multiple times. Disposable rec = ReactiveNetwork.observeInternetConnectivity(new SocketInternetObservingStrategy(), "https://google.com")
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(isConnectedToHost -> {
if (isConnectedToHost) {
getApp().setConnected(true);
if(dialog!=null){
dialog.dismiss();
}
} else {
getApp().setConnected(false);
showInternetDialog();
}
}); |
Hi @aldocano, In order to help you, I need more details. In standard scenario and setup, this code will work correctly. There must be something specific with your network, device or app. |
I happens in all devices, while i watch a online video in spans the dialog of no internet connection, i dont know why, because the device has continuous internet connection. |
@aldocano Al |
Which one is the better way to continuously check the internet connection? |
If it's not necessary, it's better to check connectivity only once. |
Sorry for late response, i need to continuously check it, maybe pinging server returns some timeouts and therefore it displays the not connected dialog.? |
Then you should use method with |
The server is google firebase server url. Strange that this occurs in strange conditions. |
Sure. You can use the following observable: Observable<Boolean> observeInternetConnectivity(int interval, String host, int port, int timeout) For example: Disposable rec = ReactiveNetwork.observeInternetConnectivity(5000, "https://google.com", 80, 1000)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(isConnectedToHost -> {
// ...
}); You can find more methods here: https://github.com/pwittchen/ReactiveNetwork#observing-internet-connectivity I know, this API became unconveninent when number of parameters and different variantions grew, but I have plan to fix this. |
Thank you for the help i will try and let you know if there is any difference. Thanks. |
There's no further discussion in more than one month, so I'm closing it. |
OS: Android 7.0
Emulator: Nexus S - Nougat API 24
When I turn off wifi on my phone, I return the result:
connectivity.isAvailable() == true
It happens when turn on/off Wifi on phone several times.
The text was updated successfully, but these errors were encountered: