Loading ...
Sorry, an error occurred while loading the content.

YUI connection timeout at times

Expand Messages
  • swamyveera
    Hi there, I am using the YUI connection object to make some requests, but at times, for no reason, the connection times out. This is my code, is there
    Message 1 of 4 , Jul 7, 2008
    • 0 Attachment
      Hi there,
      I am using the YUI connection object to make some requests, but at
      times, for no reason, the connection times out. This is my code, is
      there something wrong with it? When i call the function, it times out
      and times, and a call again to the function is a success. It happens
      now and then. Any suggestions?

      YAHOO.tally.removeDonation = function(batchName,donation,barcodeType) {
      var div = document.getElementById('divDonations');
      var handleSuccess = function(o){
      if(o.responseText !== undefined){
      var response=YAHOO.lang.JSON.parse(o.responseText);
      div.innerHTML=response.return;
      document.getElementById('divResponse').innerHTML="Response from
      server:
      "+o.responseText+"<br>["+o.statusText+"]["+o.status+"]["+o.tId+"]<br>+["+o.getAllResponseHeaders+"]";
      }
      }
      var handleFailure = function(o){
      div.innerHTML += "<li>Transaction id: " + o.tId + "</li>";
      div.innerHTML += "<li>HTTP status: " + o.status + "</li>";
      div.innerHTML += "<li>Status code message: " + o.statusText + "</li>";
      }
      var callback =
      {
      success: handleSuccess,
      failure: handleFailure,
      argument: { foo:"foo", bar:"bar" },
      timeout: 1500
      };
      var sUrl =
      'testTallyManager.php?type=TallyManager&function=removeDonationFromBatch&batchName='+batchName+"&donation="+donation+"&barcodeType="+barcodeType;
      var request = YAHOO.util.Connect.asyncRequest('GET', sUrl, callback);
      }

      Thanks
      Vru
    • tssha
      ... ... You have defined the callback s timeout property with a value of 1500 (milliseconds), which means if a request has not reached readyState 4
      Message 2 of 4 , Jul 7, 2008
      • 0 Attachment
        --- In ydn-javascript@yahoogroups.com, "swamyveera" <swamyveera@...>
        wrote:
        >
        > Hi there,
        > I am using the YUI connection object to make some requests, but at
        > times, for no reason, the connection times out. This is my code, is
        > there something wrong with it? When i call the function, it times out
        > and times, and a call again to the function is a success. It happens
        > now and then. Any suggestions?

        <snip>

        > var callback =
        > {
        > success: handleSuccess,
        > failure: handleFailure,
        > argument: { foo:"foo", bar:"bar" },
        > timeout: 1500
        > };

        You have defined the callback's timeout property with a value of 1500
        (milliseconds), which means if a request has not reached readyState 4
        (COMPLETE) in that time, the transaction will be aborted.

        If this is not desired, remove it and your transactions will proceed
        without a time-to-complete threshold.

        Regards,
        Thomas
      • swamyveera
        Hi thomas thanks for the reply, that s what i thought too, but was just wondering why it fails only at times, could it be the network itself? i would
        Message 3 of 4 , Jul 7, 2008
        • 0 Attachment
          Hi thomas
          thanks for the reply, that's what i thought too, but was just
          wondering why it fails only at times, could it be the network itself?
          i would definitely like to have a time out, may be just increase the
          value time out.

          Thanks
          Vru
        • Eric Miraglia
          Vru, With a timeout of 1500 ms, you would expect it to timeout sometimes -- http requests do not return in a predictable amount of time, and 1.5 seconds is not
          Message 4 of 4 , Jul 8, 2008
          • 0 Attachment
            Vru,

            With a timeout of 1500 ms, you would expect it to timeout sometimes -- http requests do not return in a predictable amount of time, and 1.5 seconds is not an uncommon request/response duration.  Many variables, including your network performance and the speed and performance of the server you are requesting from affect the ultimate response time.

            You're right that bumping up that number significantly should ameliorate the problem.

            Regards,
            Eric


            On Jul 7, 2008, at 11:05 PM, swamyveera wrote:

            Hi thomas
            thanks for the reply, that's what i thought too, but was just
            wondering why it fails only at times, could it be the network itself?
            i would definitely like to have a time out, may be just increase the
            value time out.

            Thanks 
            Vru


          Your message has been successfully submitted and would be delivered to recipients shortly.