I'm developing for iOS and I have a lot of issues with the timeout error, not depending from server side.
If I try immediately after a timeout it works well, both on simulator and physical devices, situation is worse if connected to a 3G network of course.
A workaround could be setting a shorter timeout and try a number of time, before assuming that the server is not answering. If I try this manually this works.
What could be an elegant pattern to force a second try and manage better the error?
Thanks
var xhr = Ti.Network.createHTTPClient(); xhr.url = url; xhr.timeout = 4000; xhr.onload = function() { Ti.App.fireEvent('app:actiononload', {data: this.responseText}); } Ti.App.addEventListener('app:actiononload', function(obj){ // Success code }); xhr.onerror = function(e) { //Error code Ti.API.info(e); } xhr.open("GET", url); xhr.send();