1. #1
    Sencha User anthonyterrell's Avatar
    Join Date
    Mar 2012
    Location
    Albany, NY
    Posts
    30
    Vote Rating
    0
    anthonyterrell is on a distinguished road

      0  

    Default Answered: Server TimeOut function for connectivity?

    Answered: Server TimeOut function for connectivity?


    I'm in the process of building a sencha app that will have a fall back offline feature. Looking at a few other discussions and articles it appears there are a few different ways of detecting internet connectivity and when it's it lost.

    The basic suggestion was using:
    Code:
    navigator.onLine
    Though reports say this is usually based off if a device is in airplane mode or offline mode rather than if there is an actual drop in connectivity.

    I'm thinking the best route might be to set some sort of ping function to the server in which I'm grabbing JSON data from, then setting an aggressive timeout for it. If the time out is met then I can call a function to change the header and alter the content displayed. At least that's what I'm thinking and wondering if anyone has already built something along these lines?

    Am I missing any other built in functions that might be able to easily do this? Any other recommendations?

    Thanks in advance!
    Anthony Terrell - Developer
    [twitter] - [forrst]

  2. navigator.onLine should take into account if the device looses connection in any way, this is up to the platform and browser though.

    You can do a ping Ajax call. Ajax calls do have a timeout that will fire the failure callback.

  3. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,641
    Vote Rating
    898
    Answers
    3573
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    navigator.onLine should take into account if the device looses connection in any way, this is up to the platform and browser though.

    You can do a ping Ajax call. Ajax calls do have a timeout that will fire the failure callback.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  4. #3
    Sencha User anthonyterrell's Avatar
    Join Date
    Mar 2012
    Location
    Albany, NY
    Posts
    30
    Vote Rating
    0
    anthonyterrell is on a distinguished road

      0  

    Default


    Quote Originally Posted by mitchellsimoens View Post
    navigator.onLine should take into account if the device looses connection in any way, this is up to the platform and browser though.

    You can do a ping Ajax call. Ajax calls do have a timeout that will fire the failure callback.
    Thanks for the heads up. I tested the navigator.online feature with a basic two tab page. The first page said welcome and the second would display online/offline based on status. I switched to airplane mode and my second page still said I was online.

    Code:
    cls:'status',
    title: '?',     
    html: navigator.onLine?'online':'offline'
    Anthony Terrell - Developer
    [twitter] - [forrst]

  5. #4
    Sencha User anthonyterrell's Avatar
    Join Date
    Mar 2012
    Location
    Albany, NY
    Posts
    30
    Vote Rating
    0
    anthonyterrell is on a distinguished road

      0  

    Default


    Revisiting this particular piece of this project, I am still getting the same issue. However when it comes to testing this, I now think I will have to deploy as an iOS app and sync over. When I save the site to my home screen and leave the app to turn on airplane mode. The app will not launch since it's trying to access the website anyways.

    Testing this in browser, I am able to get the result I need.
    Anthony Terrell - Developer
    [twitter] - [forrst]