Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-799] setTimeout on XHR varies based on send w/data or without

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2011-04-17T01:54:16.000+0000
Affected Version/sn/a
Fix Version/sRelease 1.3.0
ComponentsiOS
Labelsn/a
ReporterNolan Wright
AssigneeBlain Hamon
Created2011-04-15T02:36:41.000+0000
Updated2011-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);

Comments

  1. Jeff Haynie 2011-04-15

    (from [5f59e16c4abbe584f5a470a3590304135b10789a]) Closes #799 http://github.com/appcelerator/titanium_mobile/commit/5f59e16c4abbe584f5a470a3590304135b10789a"> http://github.com/appcelerator/titanium_mobile/commit/5f59e16c4abbe...

JSON Source