Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting lack of internet connections.

Status
Not open for further replies.

bigdavidt

Programmer
Feb 12, 2004
52
0
0
US
We have an Access application with a subroutine that posts information to the GeckoBoard cloud service several times a day. Sometimes the connection fails, so I have added code to the subroutine that will make a second and a third attempt so as to minimize the number of fails. Lately I found out that two of the network computers that use the application have had their internet connections disabled on purpose. What can I do to help our application detect this and not try to run the subroutine?

The subroutine is like this:

Public Sub PushToGecko(gURL, payload)
On Error GoTo Err_SomeName

Dim NumOfTries As Long

'Dim objSvrHTTP
Set objSvrHTTP = CreateObject("MSXML2.ServerXMLHTTP")

Dim strT As String

Err_TryAgain:

objSvrHTTP.Open "POST", gURL, False
'MsgBox (payload)
objSvrHTTP.Send (payload)

'MsgBox (CStr(objSvrHTTP.status))

If objSvrHTTP.Status <> 200 Then
Call SendEmail("cbrown@prestwick-group.com", "None", "Dashboard Fail", "None", "One dashboard push has failed. Please fix me." & gURL)
'Call reportFailure("Dashboard fail", "Push to Gecko <> 200")
End If

Set objSvrHTTP = Nothing

Exit Sub

Err_SomeName:

If NumOfTries < 3 And (Err.Number = -2147220975 Or Err.Number = -2147483638 Or Err.Number = -2147012894 _
Or Err.Number = -2147220973 Or Err.Number = -2147012866) Then
NumOfTries = NumOfTries + 1

GoTo Err_TryAgain
End If

'Any unexpected error.
Call LogError(Err.Number, Err.description, "ReorderTrelloCards, cardID " & cardID)
Resume Next

End Sub
 
Try looking for error 80072EE7 (-2147012889) being returned - this means DNS failed and is a reasonable indicator that an internet connection is down (MS themselves pretty much do this to show network status in the Windows status bar - they do an DNS lookup of If that succeeds they then try and GET a file from the looked-up address to be really sure, but just a failed DNS should be good enough in most circumstances)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top