Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Remote server timeout - retry when signal sucks?

$
0
0

Hi Guys,

Is there a best practice in terms of getting your app to re-try a remote server call in the event of bad connectivity or timeout?

I have a generic function that handles all my remote calls;

function doQuery(url) {
    var xhr = Ti.Network.createHTTPClient({
    onload: function(e) {
            if(xhr.responseText != '0') {
                handleResponse(xhr.responseText); // Success
            }
        },
        onerror: function(e) { 
            // Failure...  Can I call myself again?  settimeout doQuery(url) ?
        },
        timeout:5000
    });
    xhr.open("GET", url);
    xhr.send();
}

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>