Uploaded image for project: 'Appcelerator - INBOX'
  1. Appcelerator - INBOX
  2. AC-2785

Sporadic connection failure with HTTPClient.

    Details

      Description

      The following error is thrown approximately 75% of the time when requesting web service via HTTPClient:

      Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0x6d14d80

      {NSUnderlyingError=0x6d13ca0 "The operation couldn't be completed. (kCFErrorDomainCFNetwork error -1005.)", NSLocalizedDescription=A connection failure occurred}

      Cannot resolve.

        Activity

        Hide
        pdowsett Paul Dowsett added a comment -

        In order for us to progress this issue, please edit your ticket to include a proper Use-case.

        Also, please provide a link to the Q&A question where you have sought help from the community prior to raising this ticket. Kindly read the Submitting Bug Reports guide for more info about this.

        Thank you

        Show
        pdowsett Paul Dowsett added a comment - In order for us to progress this issue, please edit your ticket to include a proper Use-case . Also, please provide a link to the Q&A question where you have sought help from the community prior to raising this ticket. Kindly read the Submitting Bug Reports guide for more info about this. Thank you
        Hide
        robmarston Rob Marston added a comment -

        Apologies. The community post can be found at http://developer.appcelerator.com/question/120964/sporadic-server-error-a-connection-failure-occurred. Here's the use case:

        var curr_marble = {id:1);
        var list =

        {id:2025}

        ;
        var user =

        {username:'USERNAME',password:'PASSWORD'}

        ;
        var auth = 'Basic 'Titanium.Utils.base64encode(user.username':'+user.password);
        var xhr = Titanium.Network.createHTTPClient();
        xhr.setTimeout(0);
        xhr.onerror = function(e)

        { Titanium.API.info(e.error); }

        ;
        xhr.onload = function()

        { Titanium.API.info(this.responseText); }

        ;
        xhr.open("POST","http://api.marblejarapp.com/1/marbles.json");
        xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
        xhr.setRequestHeader('Authorization',auth);
        if (Titanium.Network.online) {
        xhr.send(

        {marbletype:curr_marble.id,list:list.id}

        );
        } else

        { alert("Network unavailable, please try again."); }

        ;

        *My username and password have been obfuscated for security purposes. Happy to send you actual login credentials.

        Originally I had though the sound (local mp3) that played before the HTTP request was initiated was causing the error but as it turns out it happens regardless. Additional examples and files available.

        Show
        robmarston Rob Marston added a comment - Apologies. The community post can be found at http://developer.appcelerator.com/question/120964/sporadic-server-error-a-connection-failure-occurred . Here's the use case: var curr_marble = {id:1); var list = {id:2025} ; var user = {username:'USERNAME',password:'PASSWORD'} ; var auth = 'Basic ' Titanium.Utils.base64encode(user.username ':'+user.password); var xhr = Titanium.Network.createHTTPClient(); xhr.setTimeout(0); xhr.onerror = function(e) { Titanium.API.info(e.error); } ; xhr.onload = function() { Titanium.API.info(this.responseText); } ; xhr.open("POST","http://api.marblejarapp.com/1/marbles.json"); xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); xhr.setRequestHeader('Authorization',auth); if (Titanium.Network.online) { xhr.send( {marbletype:curr_marble.id,list:list.id} ); } else { alert("Network unavailable, please try again."); } ; *My username and password have been obfuscated for security purposes. Happy to send you actual login credentials. Originally I had though the sound (local mp3) that played before the HTTP request was initiated was causing the error but as it turns out it happens regardless. Additional examples and files available.
        Hide
        pdowsett Paul Dowsett added a comment -

        It seems the user has found the answer but not updated this ticket. :/

        The solution was:

        xhr = Titanium.Network.createHTTPClient({enableKeepAlive:false});

        Show
        pdowsett Paul Dowsett added a comment - It seems the user has found the answer but not updated this ticket. :/ The solution was: xhr = Titanium.Network.createHTTPClient({enableKeepAlive:false});
        Hide
        pdowsett Paul Dowsett added a comment -

        Closing after 30 days of inactivity.

        Show
        pdowsett Paul Dowsett added a comment - Closing after 30 days of inactivity.

          People

          • Assignee:
            tguntharp Tony Guntharp
            Reporter:
            robmarston Rob Marston
          • Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development