I'm working on a proof-of-concept for my boss, so any help would be very appreciated.
My app calls does a JSONP call to a RESTful API. Over Wi-fi the app works flawlessly both in emulator and on the device.
When using SpeedLimit to restrict the bandwidth on the computer or trying to run the app over 3G on the phone, the calls time out 100% of the time.
As of today, I'm using 1.4.2. I was under the impression the setTimeout problem supposed to be fixed for the iPhone in this version. Is this not the case?
I've tried passing the timeout value as an integer, string and within brackets (as an array?) but it doesn't seem to make a difference.
I've also tried implementing pretty much every one of home-grown timeout alternatives from this forum to no avail.
If someone has a solution, I'd be very interested in hearing it. Thank you for your help in advance.
In my testing it appears that you must set the timeout right after the constructor but before the actual call to open.
var xhr = Titanium.Network.createHTTPClient(); xhr.setTimeout(60000); xhr.open("POST", url); xhr.send();
But this doesn't seem to.
var xhr = Titanium.Network.createHTTPClient(); xhr.open("POST", url); xhr.setTimeout(60000); xhr.send();
I assume the reason is that the open method needed the timeout value to have been set so it knew what the timeout is for that call. If that's truly the case, the documentation ought to be updated to reflect it.
BTW - This works for me in 1.4.1 and 1.4.2. It looks like the default timeout is around 15 seconds on iOS deveices and my calls had returned in less than that time but some have gone one for 40-50 seconds and the timeout being set to 60000 worked for me.