Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19458] iOS: Timeout property of Ti.Network.HttpClient is being ignored

GitHub Issuen/a
TypeBug
PriorityNone
StatusOpen
ResolutionUnresolved
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
ReporterEduardo Gomez
AssigneeUnknown
Created2015-09-02T16:33:49.000+0000
Updated2018-02-28T19:55:16.000+0000

Description

Issue Description

Running the sample code below, we're trying to set a very high timeout for our HttpClient request. (It's a necessary change for our test environment.) Unfortunately, our increase seems to be ignored, and the connection always times out after 120 seconds.

Runnable Test Case

The variable ‘someurl’ can be replaced with the url of a slow responding API (an API which takes longer to respond).
var makeRestAPICall = function() {
    // create the titanium HTTPClient
    var httpClient = Titanium.Network.createHTTPClient();

    //var someurl = "http://jsonplaceholder.typicode.com/posts/";
    var someurl = "http://fake-response.appspot.com/?sleep=3000"
    httpClient.setTimeout(300000);

    /**
     * httpClient error handler
     * @method onerror
     * @param {} e
     * @return
     */
    httpClient.onerror = function(e) {
        Ti.API.info("API ERROR ", e.error);
    };

    /**
     * httpClient Success Handler if and when response comes back the success function is called
     * @method onload
     * @return
     */
    httpClient.onload = function(e) {
        Ti.API.info("On load " + e);
    };

    // open the connection and set the appropriate request headers
    httpClient.open("POST", someurl, true);
    httpClient.setRequestHeader("Content-Type", "application/json; charset=utf-8");

    // send the request
    httpClient.send("");
};

makeRestAPICall();

Comments

  1. Alberto Marcone 2015-09-16

    the setTimeout doesn't seem to work for me either.

JSON Source