So i have a client request - i can see it go to the client, and i can see the response.
I have a timeout in my titanium code of 4500 (4.5 seconds).
What I don't understand is that the app itself will take 12 seconds to send the message, and it doesn't time out!
My code looks a bit like this (truncated for clarity)
var start = new Date().getTime();
var xhr = Ti.Network.createHTTPClient({
timeout: 4500,
onload : function() {
alert("success time " + (new Date().getTime() - start));
//other stuff here
},
onerror : function(error) {
alert("fail time " + (new Date().getTime() - start));
//error handling here
}
});
xhr.open(args.method, baseUrl + args.url);
setRequestHeaders(xhr, that, args.sessionId);
xhr.send(JSON.stringify(args.object));
As you can see above, i've timed the sending process. It often takes 12 seconds for the message to be sent, as shown in the timer that i've setup. What is weird is
titanium doesn't kill the process and run my onerror
titanium will actually successfully send the message, even with the timeout at 4500 and the entire message taking 12000!
How do i get titanium to just stop after the timeout has occurred? I don't want my users sitting looking at the screen for ages, it makes my app look stupid.
(also, i don't know where else to request this - can someone at appcelerator change the "Q&A search" so that results are orderable by time asked? Currently, when i look up "timeout httpclient" the first result is from 2 years ago, and everything on the first page is from 2-3 years ago. Given the changes in appcelerator over the last year, i don't find it useful to see questions from so long ago!)