Testing for Choked internet connection

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Testing for Choked internet connection

Post by doobox » Tue Jul 24, 2012 8:06 am

Hi there,

The problem i have is testing for a case where an internet connection is so choked that any normal browser will return an error when trying to access a webpage.

Livecode apps aside.. I see this in normal use, when uploading a video to vimeo for example.
While the upload is in progress, trying to access any webpage in any browser returns an error, as if i were trying to access a page that does not exist.
I assume this is because the connection is so choked with the video upload.

Now.. where my app is concerned.. Testing how the app handles this scenario reveals something unexpected to me.
First i test for an internet connection, each time the app tries to do it's thing, every 10 minutes.

Code: Select all

function internetConnectionTest
   put URL "http://www.google.com" into tconnectionTest
   put URL "http://www.yahoo.com" into tconnectionTestTwo
   put "Starting checks..." into field "loaderMessage"
   if tconnectionTest is empty and tconnectionTestTwo is empty then
      return false
   else
      return true
   end if
end internetConnectionTest
This always returns false if i switch of my connection (expected)
This always returns true if my connection is switched on (expected)

But.. the big.. But....
So my code knows we have a connection so continues onward to run a similar function....See comments in code....

Code: Select all

repeat with x = 1 to the number of items of  pTheUrlArray
      put item x of pTheUrlArray into tTheCurrentUrl
      put item x of tEmailArray into tTheCurrentEmail
      put "Checking " &  truncateTheUrl(tTheCurrentUrl,20) into field "loaderMessage"
      put URL tTheCurrentUrl into tWebsiteResponse
      if tWebsiteResponse is empty then

// In the case of a choked connection tWebsiteResponse is always empty even though it passed the connection test millisecons ago.

     else

// Never gets here with a choked connection.

end if
// and the code continues doing other stuff

So is there a better test i can to on the connection in stage 1...?

Kind regards
Gary
Kind Regards
Gary

https://www.doobox.co.uk

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Testing for Choked internet connection

Post by doobox » Tue Jul 24, 2012 8:09 pm

I have employed a temporary workaround ..

Tests seem to show that the url command times out after about 15 seconds. I am not sure what causes the time out but it if has not succeeded in 15 seconds on my system it times out.
So i put a few extra lines in the internet check function for the time being :

Code: Select all

function internetConnectionTest
   put the seconds into tPreCheckSeconds
   put URL "http://www.google.com" into tconnectionTest
   put URL "http://www.yahoo.com" into tconnectionTestTwo
   put the seconds into tPostCheckSeconds
   put tPostCheckSeconds - tPreCheckSeconds into tCheckDuration
   put "Starting checks..." into field "loaderMessage"
   if tCheckDuration > 20 then
      return "choked"
   end if
   if tconnectionTest is empty and tconnectionTestTwo is empty then
      return false
   else
      return true
   end if
end internetConnectionTest
I would love to know though, if this timeout time of 15 seconds i am seeing is standard and will be the same across all systems.
Kind Regards
Gary

https://www.doobox.co.uk

Post Reply