Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-12846] Android: Timeout property not working for Network calls

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-03-26T22:20:31.000+0000
Affected Version/sRelease 3.0.0, Release 3.0.1, Release 3.0.2
Fix Version/s2013 Sprint 07 API, 2013 Sprint 07
ComponentsAndroid
Labelsandroid, mobilesdk, titanium
ReporterAshish Nigam
AssigneeIngo Muschenetz
Created2013-02-25T07:42:46.000+0000
Updated2013-11-07T18:03:54.000+0000

Description

Find the sample code below to reproduce the same.
var win = Ti.UI.createWindow({
    backgroundColor : '#ffffff'
});
var url = 'https://www.google.com';
if (Ti.Network.online) {
    var xhr = Ti.Network.createHTTPClient({
        timeout : 0,
        validatesSecureCertificate : false
    });
    xhr.onload = function(e) {// Onload
        Ti.API.info('onload:' + this.status + xhr.status + xhr.getStatusText() + JSON.stringify(e));
    };
    xhr.onerror = function(e) {
        alert('e.error:' + e.error + ':status:' + xhr.status + xhr.statusText);
        Ti.API.info(JSON.stringify(e));
    };
    xhr.open('GET', url);
    xhr.send();
}
win.open();

Comments

  1. Vishal Duggal 2013-03-18

    timeout=0 is an invalid value. 0 means no timeout.
  2. Ashish Nigam 2013-03-25

    Hi Ingo, you understood well and yes, i tried various different values and none of them worked. I am reopening this ticket.
  3. Ashish Nigam 2013-03-25

    I tried various different values and none of them worked. "0" is just an example value.
  4. Vishal Duggal 2013-03-26

    I just tried hitting http://www.google.com:81 with a timeout property > 0 (I tried 50, 100, 150) (Port hidden behind firewall. Expect timeout). I always got the onError callback. Agreed that the message right now is not descriptive which we will fix. But debugging showed that we did get a ConnectionTimeout exception. Tried this on S3 running 4.1.1 and S2 running 2.3.6.
  5. Dhirendra Jha 2013-04-11

    Verified With - SDK - 3.1.0.v20130409124549 Appcelerator Studio - 3.1.0.201304091724 OS - Montain Lion (v10.8) Verified the last comment made by Vishal and got the same. Hence closing this issue.

JSON Source