I just want to add that using a hostname address can cause the long hangs. If the user’s wifi is connected but something goes wrong on the wifi end you still get long hangs due to DNS resolving overriding the block timeout settings. To get past this you need to use a actual IP address and your timeout issues disappear, as its not ICMP protocol you can’t just ping any old server such as 4.4.4.4 as there TCP ports are blocked on the standard 80 (maybe there is one somewhere).
So what I do is ping my own servers and have several fallback pings found out on the web from various services. If the fallbacks fail I then throw away that fallabck and use several more from a pool of addresses next time I check if these fail then its likely no connection.
Fallbacks are good for backups. No one wants to have to submit and wait week just to get the ip working again. Alternatively you can pull your configs of pings from a server. Another option is to make small request to script that returns OK from your server.