I have used "dns_gethostbyname()" to resolve the DNS url to check if the internet (net) is available on the wifi AP that ESP32 was connected. The solutions works. In the call-back function, I check if ipaddr == NULL then the net is not available.
I tried it using "google.com" first. It reported the net is available.
Next, I disabled the internet connection by removing the WAN connection to my AP.
The problem is that, dns_gethostbyname() kept on reporting the net was available. I think it could resolve the DNS locally.
Further, I tried the example with "amazon.com" & it started to report no Internet, correctly.
I connected the physical WAN cable to the AP & tried "amazon.com", it showed the net was available, correctly.
Again after removing the WAN cable from AP, so as to disconnect internet from wifi, I tried the example with "amazon.com" & it showed the net connected, which was wrong.
I think, once DNS is resolved online, AP saves a copy & on subsequent call to resolve DNS, it does not need internet.
So resolving DNS using dns_gethostbyname() may not yield correct answer every time.
Does anyone have a solution to this.
Checking Internet connectivity using ESP32
Re: Checking Internet connectivity using ESP32
I think it is your DNS cache on your access point which need to be cleared.
If you just want to test it you network is up runnining or down, you can use http get and check og you get the correct reply or use ip ping, know there is some ping library out there.
If you just want to test it you network is up runnining or down, you can use http get and check og you get the correct reply or use ip ping, know there is some ping library out there.
Re: Checking Internet connectivity using ESP32
Thanks for the reply.
DNS cache on the access point will not be in our control, once the devices are deployed to different customers !
As you suggested, http get or ping to an internet resource could be better way out.
DNS cache on the access point will not be in our control, once the devices are deployed to different customers !
As you suggested, http get or ping to an internet resource could be better way out.
Re: Checking Internet connectivity using ESP32
When you cant use DNS, then you have the other optioner, I have used http get and IT works, have seen a ping lib, but not testede any.
Re: Checking Internet connectivity using ESP32
Yes. Good suggestion.
Who is online
Users browsing this forum: No registered users and 184 guests