ReactiveNetwork
ReactiveNetwork copied to clipboard
InternetObservingSettings custom host NIC shutdown
InternetObservingSettings with a custom host and port does not respond to the shutdown of the custom host network interface.
// Never fired error yet. Just for stub
ErrorHandler errorHandler = new ErrorHandler() {
@Override
public void handleError(Exception exception, String message) {
Logs.error(this, getString(R.string.internetobservingsettings_error)
+message +getString(R.string.exception)+exception, exception);
}
};
// Config for monitoring server avaliability
InternetObservingSettings settings =
InternetObservingSettings.builder()
.host(getServerAddress().getHostString())
.port(getServerAddress().getPort())
.strategy(new SocketInternetObservingStrategy())
.initialInterval(INITPINGTIMEOUT)
.interval(PINGTIMEOUT)
.errorHandler(errorHandler)
.build();
// Server avaliability consumer
Consumer<Boolean> serviceConsumer = new Consumer<Boolean>() {
@Override
public void accept(Boolean aBoolean) throws Exception {
Logs.info(this,getString(R.string.consumer_accept)+aBoolean);
connectToServer();
}
};
// All RX kernel there
d=ReactiveNetwork.observeInternetConnectivity(settings)
.subscribeOn(Schedulers.io())
.subscribe(serviceConsumer);
If disable WiFi on phone or the WiFi router between the server and the phone, the lost connection event is thrown. And if turn off the network card on the server, the loss of communication event is not thrown.
Have you checked the situation after interval in milliseconds defined in PINGTIMEOUT field? Observing mechanism uses polling for checking Internet connectivity every given amount of time. It should detect the situation that the device doesn't have an Internet connection. Are you sure, your device to which the phone is connected (e.g. router with WiFi) doesn't have the access to the Internet?
PINGTIMEOUT 2 seconds. I need to monitor the status of the server in the internal network of the enterprise. As I understood from the description it is possible to specify custom settings of ip and port of the host of an internal network. Monitoring the fall of access to the server works when the router is disconnected and the network is disconnected on the phone. But shutdown and inclusion of the network controller of the server through time, more than 2 seconds is not caught.
It's strange.... I'll have a look on that. I cannot to reproduce this situation in an enterprise environment, but I can check it on my simple home router. Maybe there are more variables determining such situation.