Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reachability takes too long to fail when connected to WIFI without internet

Tags:

xcode

cocoa

Hi there I have been using reachability class and everything works fine; except for ...

When the device is connected to wifi, and for whatever reason, the wifi router does not have internet connectivity the reachability class takes too long to say that there is no internet.

It works well(fast!) when there is no network/internet connectivity at all, for instance, if the wifi is off and the device does not have a 3G connection, reachability class returns success/failure almost instantly.

To re-iterate, connected to a wifi router, where there is no internet connectivity almost takes a full minute for reachability class to return a status.

Reachability *reachability=[Reachability reachabilityWithHostName:@"www.google.com"];
    NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];
    if(remoteHostStatus == NotReachable) { 
 ............

My Code

Any suggestions?

Thanks

like image 298
Veeru Avatar asked Dec 16 '25 16:12

Veeru


1 Answers

i just tried this

Reachability *reachability=[Reachability reachabilityForInternetConnection];

Looks like it works! Since i just wanted to see if the internet is available or not

Thanks

like image 74
Veeru Avatar answered Dec 19 '25 07:12

Veeru



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!