[TIMOB-799] setTimeout on XHR varies based on send w/data or without
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2011-04-17T01:54:16.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 1.3.0 |
Components | iOS |
Labels | n/a |
Reporter | Nolan Wright |
Assignee | Blain Hamon |
Created | 2011-04-15T02:36:41.000+0000 |
Updated | 2011-04-17T01:54:16.000+0000 |
Description
from premium ticket:
http://helpdesk.appcelerator.net/tickets/2011">http://helpdesk.appcelerator.net/tickets/2011
if you have a data object in the xhr.send, the timeout seems to be 72 seconds vs. the 30 seconds that is specified via setTimeout
// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');
// create tab group
var tabGroup = Titanium.UI.createTabGroup();
//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});
var label1 = Titanium.UI.createLabel({
color:'#999',
text:'Waiting for response...',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win1.add(label1);
//
// create controls tab and root window
//
var win2 = Titanium.UI.createWindow({
title:'Tab 2',
backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({
icon:'KS_nav_ui.png',
title:'Tab 2',
window:win2
});
var label2 = Titanium.UI.createLabel({
color:'#999',
text:'I am Window 2',
font:{fontSize:20,fontFamily:'Helvetica Neue'},
textAlign:'center',
width:'auto'
});
win2.add(label2);
//
// add tabs
//
tabGroup.addTab(tab1);
tabGroup.addTab(tab2);
// open tab group
tabGroup.open();
var start;
var xhr = Ti.Network.createHTTPClient();
xhr.setTimeout(30000);
xhr.onload = function()
{
label1.text = 'Received the response.';
};
xhr.onerror = function()
{
var now = new Date();
var time = (((now - start) / 1000) | 0);
label1.text = 'Registered error: time passed = ' + (now-start) + ' seconds';
};
// use any ip address that is not on the network
var notExistIP = 'http://192.168.1.23';
// use any unreachable IP address
xhr.open('GET',notExistIP);
start = new Date();
var data = {
value1: 'value1',
value2: 'value2'
};
// it works if no data is sent
//xhr.send();
// it doesn't work if data is sent
xhr.send(data);
(from [5f59e16c4abbe584f5a470a3590304135b10789a]) Closes #799 http://github.com/appcelerator/titanium_mobile/commit/5f59e16c4abbe584f5a470a3590304135b10789a"> http://github.com/appcelerator/titanium_mobile/commit/5f59e16c4abbe...