Hi. What is the best method for checking for an internet connection (desktop)? I am using AirTable and need to make sure there is an internet connection before it can connect to the table. I searched the forum and found a couple of suggestions, and this is the one I am contemplating using now:
Function InternetIsConnected as Boolean
Dim http As New HTTPSocket
http.yield = True
dim ih as InternetHeaders = (http.GetHeaders("http://www.google.com", 1))
return (ih <> nil)
It depends if people can get to google in the areas that you’re deploying to (i.e. not china).
It also depends if their modem/dns looks up and returns a result in 1 second or less, might want to up that 1 to 10.
If you’re checking for a connection to airtable, why not try the connection to airtable.com ?
This will be better than a ping for what you need as there’s no guarantee that ping isnt blocked at the users site.
You could also use your standard call to airtable (httpsocket.get?) and see if that times out, saving yourself a wasted call/bandwidth on some headers that you will be throwing away (this is dependent on how often you do this).
No. Try what you want to do and see if you succeed.
With firewalls, proxies and maybe a non available DNS server, you may be able to download something, but can’t get connection to google.
It is more or less useless to test for an internet connection prior to connecting to “the real thing”. The connection can fail at any time during “the real thing”. Deal with that scenario.
Thanks for the replies everyone. I agree with seeing that the app can connect to AirTable since that’s what it has to connect to anyway. I’ll give it a go and see what happens
Yeah the usual issues is that if you dont just try connecting to the thing you actually want to use you can get false positives
You ping of some other server says “hey this should wrk” but the service isn’t responding to your software for some reason
Look at the frequency of things like people posting on this forum about “Hey is this web site (or documentation.xojo.com) up for you ?” where some people can reach the service & others cant.
IMHO the best way is to download a small stub file from a known source. Put a text file on your own server where you know the contents, then download it and read the data to verify it’s correct.
Just because you receive a response from google doesn’t mean you’re receiving a response from google. For example, you could be actually reaching the router’s log-in page.
You need to verify content to make sure that a valid connection exists.
Simultaneously, @Eli Ott makes a great point that any net code needs to be robust enough to handle a failure at any point during the connection.
Hello Sir, care to share how you implement to get the public IP from ipify? Thank you![/quote]
If you have a website, you can easily implement this on your own. Create a file with text editor with the following and name it as a .shtml file, example getmyip.shtml. Must be .shtml otherwise won’t work. Upload to your website. The file return just your public IP address. You capture that. Of course you can also use it with your browser.
Or, if shtml is not working but php does, then you can create for instance a file named index.php with this contents and copy it to a subfolder on your webserver: