Titanium (Community)
  1. Titanium (Community)
  2. TC-79

Sporadic connection failure with HTTPClient.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Resolution: Invalid
    • Component/s: Mobile
    • Environment:

      Titanium Developer 1.2.2., Titanium SDK 1.6.2, IOS SDK 4.2 on Mac OS X 10.6.6.

      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
        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
        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
        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
        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
        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
        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
        Paul Dowsett added a comment -

        Closing after 30 days of inactivity.

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

          People

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

            Dates

            • Created:
              Updated:
              Resolved: