Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2785] Sporadic connection failure with HTTPClient.

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2011-06-25T04:03:54.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelshttpclient, iphone, mobile, onerror, xhr
ReporterRob Marston
AssigneeTony Guntharp
Created2011-06-13T14:04:47.000+0000
Updated2016-03-08T07:47:42.000+0000

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.

Comments

  1. Paul Dowsett 2011-06-13

    In order for us to progress this issue, please edit your ticket to include a proper [Use-case](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-CreatingGoodUsecases). 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](http://wiki.appcelerator.org/display/guides/Contributing+to+Titanium#ContributingtoTitanium-SubmittingBugReports) guide for more info about this. Thank you
  2. Rob Marston 2011-06-13

    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.
  3. Paul Dowsett 2011-06-25

    It seems the user has [found the answer](http://developer.appcelerator.com/question/120964/sporadic-server-error-a-connection-failure-occurred) but not updated this ticket. :/ The solution was:
       xhr = Titanium.Network.createHTTPClient({enableKeepAlive:false});
       
  4. Paul Dowsett 2011-08-16

    Closing after 30 days of inactivity.

JSON Source