http module timeout

Thread is closed for posting
4 posts, 1 answers
  1. Ian
    Ian avatar
    129 posts
    Member since:
    Jun 2009

    Posted 12 May 2015 Link to this post

    Hi. There seems to be a default timeout of 60 seconds when issuing an http.request. The NS documentation seems to suggest you can change this period using HttpRequestOptions. If I want to change the timeout to, say, 5 seconds how should I do it?

    I tried using the syntax below (using both 5 and 5000) and it doesn't seem to make any difference (at least not on iOS, I haven't tried Android).

     

    http.request({url: "http://myUrl", timeout: 5, method: "GET"}).then(function (r) {
    ...
    }

    Am I doing something wrong?

    Regards, Ian

     

  2. Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 13 May 2015 Link to this post

    Hi Ian,

    We do set the timeout from the options - you can check it here:
    https://github.com/NativeScript/NativeScript/blob/master/http/http-request.ios.ts#L36

    Regards,
    Vlad
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. Ian
    Ian avatar
    129 posts
    Member since:
    Jun 2009

    Posted 13 May 2015 in reply to Vlad Link to this post

    Hi Vlad,

    I did see the code in the http-request.ios.js file which suggests that the timeout period should be specified in whole seconds (and not milliseconds) - is that correct?

    If so, should the following http request definitely timeout after 5 seconds?
        http.request({ url: "myUrl", timeout: 5, method: "GET" })...

    Adding timeout:5 clearly has some effect as the request no longer times out after 60 seconds but instead it now appears to wait indefinetly. Something's not right.

    Regards, Ian

  4. Answer
    Vlad
    Admin
    Vlad avatar
    11100 posts

    Posted 14 May 2015 Link to this post

    Hi Ian,

    You are right! The iOS timeout logic is definitely wrong (the correct value should be in milliseconds) and we immediately fixed this!

    Sorry once again for the confusion!

    Regards,
    Vlad
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top