Your phone says it's online. That does not mean the app can actually reach the internet.
Wired up a connectivity check on a health app I am building and hit a gap that felt obvious once I saw it. The OS reports "connected to wifi" the moment it associates with an access point, before DNS or the actual gateway path is confirmed. So a captive portal at an airport, a hotel router with no WAN, a home router that lost its upstream link, all read as online while every real request quietly times out.
Ended up not trusting the OS flag at all. The check now does a real DNS lookup against a known host with a short timeout before marking anything online, and only flips the app into offline mode once that actually fails. Adds a few hundred milliseconds to every check, worth it for not showing a broken screen while telling the user everything is fine.
Curious if anyone else building offline-first mobile stuff ended up doing the same thing, or found a cheaper way to tell the difference between "associated with a network" and "can actually reach the internet"?
Replies