Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2801] iOS: HTTPClient intermittently errors on HTTPS requests

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2012-04-11T19:28:56.000+0000
Affected Version/sRelease 1.5.1, Release 1.6.0, Release 2.0.0, Release 1.8.2
Fix Version/sRelease 2.1.0, Sprint 2012-08
ComponentsiOS
LabelsSupportTeam, api, rplist
ReporterAlan Leard
AssigneeMax Stepanov
Created2011-04-15T03:29:54.000+0000
Updated2012-04-30T21:48:19.000+0000

Description

Problem

The HTTPClient errors intermittently (around half the time) when making an HTTPS request. The following error message is sent:

Error Domain=ASIHTTPRequestErrorDomain Code=1 "A connection failure occurred" UserInfo=0xb236b70 {NSUnderlyingError=0xb234cf0 "The operation couldn’t be completed. Connection reset by peer", NSLocalizedDescription=A connection failure occurred}

Tested On

All platforms tested with clean builds from both Titanium Mobile 1.5.1 and 1.6.0 (pulled January 8th, 2011).
BROKEN on iPhone Simulator 4.2
BROKEN on iPod Touch 4.2
WORKS on Android Simulator 2.2
WORKS in browser (hitting the URL)

Sample Code

var win = Titanium.UI.createWindow({ backgroudColor: '#333' });
var statusLabel = Titanium.UI.createTextArea({
    top: 10, right: 10, left: 10, bottom: 45
});
win.add(statusLabel);

function runRequest() {
    var xhr = Titanium.Network.createHTTPClient();
    xhr.onload = function () {
        statusLabel.value = this.responseText;
        //Ti.API.info(this.responseText);
    };
    xhr.onerror = function (e) {
        statusLabel.value = e.error;
        Ti.API.error(e.error);
    };
    statusLabel.value = 'Waiting for response...';
    xhr.open('GET', 'https://acomsx1.cos.agilent.com/QueryOpenNotificationsCount');
    xhr.send();
}

var refresh = Ti.UI.createButton({
    title: 'Refresh',
    bottom: 10, left: 10, right: 10, height: 25
});
refresh.addEventListener('click', runRequest);
win.add(refresh);

win.open();

runRequest();

Associated Helpdesk Ticket

http://developer.appcelerator.com/helpdesk/view/64561">http://developer.appcelerator.com/helpdesk/view/64561

Comments

  1. Max Stepanov 2012-04-10

    It could be a iOS 5+ issue as explained at https://developer.apple.com/library/ios/#technotes/tn2287/_index.html#//apple_ref/doc/uid/DTS40011309 Could you try specify TLS version as suggested at http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.Network.HTTPClient.tlsVersion-property.html
       xhr.tlsVersion = Titanium.Network.TLS_VERSION_1_0;
       
  2. Varun Joshi 2012-04-10

    I have communicated this to the customer. I will let you know once he replies back.
  3. Varun Joshi 2012-04-10

    Confirmed with the customer that this issue is fixed.

JSON Source