HttpRequest and timeout

Discussion in 'Javascript' started by hugo.lafayette@gmail.com, Dec 20, 2005.

  1. Guest

    I use an HttpRequest in my web application to launch an heavy
    computation server side. The result is then send back to the browser.
    The problem I got is that when the computation took too much time, then
    I never get the result. I have to reload the page to get it.

    I assume it's because my socket connection has time out, but my event
    listener does not seems to get any event. Maybe I miss something:

    function xmlhttpChange()
    {
    // looking fo a xmlhttp "loaded"
    for (var i in nodeId2xmlHttp) {
    if ((nodeId2xmlHttp != null) && nodeId2xmlHttp.readyState ==
    4) {
    if (nodeId2xmlHttp.status==200) {
    nodeId2xmlHttp = null;
    } else {
    alert("Problem retrieving XML data (nodeId: " + i + ")");
    nodeId2xmlHttp = null;
    }
    }
    }
    }

    My question is : how to handle XMLHttpRequest timeout. Any pointers ?
     
    , Dec 20, 2005
    #1
    1. Advertising

  2. VK Guest

    wrote:
    > My question is : how to handle XMLHttpRequest timeout. Any pointers ?


    Request timeout is a system setting (this is why it's called "system
    timeout"). You cannot handle it in the standard security environment.
    Moreover you even cannot guess reliably what timeout set for a
    particular machine.

    Very approximately you can be safe within 10sec interval. You can add
    extra interval by using "something back" trick: return content header
    right away (200, text/html etc.) then start your calculations and spit
    out an empty string or someting every 5-10 sec into the open channel.

    On a really long run you should use the method applied by online
    booking systems (like Travelocity.com) Upon request you send back id of
    the result file like sid2894838292, close connection, do calculations,
    save results sid2894838292 and exit.

    Page will try to read sid2894838292 with the instructed delay (10sec,
    20sec, 30 sec)

    Nothing reliable you can do with JavaScript only.
     
    VK, Dec 21, 2005
    #2
    1. Advertising

  3. Guest

    Thanks for the quick and clear answer. It appears to me that http is
    not a "connected" mode, and must not be use like if it was. So your
    solution seems the way to go for me.
     
    , Dec 21, 2005
    #3
  4. VK Guest

    wrote:
    > Thanks for the quick and clear answer.

    You are very welcome.

    > It appears to me that http is
    > not a "connected" mode, and must not be use like if it was.


    Very true. Just to have the whole picture: modern HTTP has Keep-Alive
    request but it's support and implementation is something I wouldn't
    suggest to trust at all. Especially in anyhow serious project and
    definitely not in money transactions.
     
    VK, Dec 21, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Greg Reevosh via .NET 247

    HTTPRequest and JAVA Servlet

    Greg Reevosh via .NET 247, Oct 17, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    592
    Greg Reevosh via .NET 247
    Oct 17, 2004
  2. Dino Chiesa [Microsoft]

    Re: HTTPRequest and JAVA Servlet

    Dino Chiesa [Microsoft], Oct 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    488
    Dino Chiesa [Microsoft]
    Oct 27, 2004
  3. Greg Reevosh via .NET 247

    HTTPRequest and JAVA Servlet

    Greg Reevosh via .NET 247, Oct 31, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    412
    Greg Reevosh via .NET 247
    Oct 31, 2004
  4. Replies:
    0
    Views:
    1,440
  5. Mark Probert

    Timeout::timeout and Socket timeout

    Mark Probert, Oct 6, 2004, in forum: Ruby
    Replies:
    1
    Views:
    1,293
    Brian Candler
    Oct 6, 2004
Loading...

Share This Page