Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-19540

iOS: Ti.Network.HTTPClient does not work in synchronous mode in SDK 3.3.0+

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: Release 6.0.2
    • Component/s: iOS
    • Labels:
    • Environment:

      Mac OSX 10.9.5, Xcode 5.1 and 6.0, iOS 7.1 and 8.0, iPad Air device and Simulator

    • Story Points:
      5
    • Sprint:
      2016 Sprint 22 SDK, 2017 Sprint 02 SDK

      Description

      I took the exact code that is in the documentation for Titanium.Network.HTTPClient and it works fine as it is for all environments. I took the sample code and modified it by making the open() call synchronous ([async = false] for 3rd parameter) and it fails in SDK 3.3.0 and 3.4.0. Normally I would not use synchronous mode, however, I inherited a large project that relies on a synchronous call and it fails. The code below is the sample code with the one parameter modified. You can stick this anywhere in a simple project and you should be able to see the problem. Neither onload() or onerror() are called in SDK 3.3.0, but they are in SDK 3.2.3. I've tried on Xcode 5 and 6 and iOS 7 and 8, with the same results. It clearly seems to be a regression in SDK 3.3.0.

      	var url = "http://www.appcelerator.com";
      	var client = Ti.Network.createHTTPClient({
      		// function called when the response data is available
      		onload : function(e) {
      			Ti.API.info("Received text: " + this.responseText);
      			alert('success');
      		},
      		// function called when an error occurs, including a timeout
      		onerror : function(e) {
      			Ti.API.debug(e.error);
      			alert('error');
      		},
      		timeout : 5000 // in milliseconds
      	});
      	// Prepare the connection.
      	
      	// BUG:
      	// This code is the sample code from the documentation simply added to the doClick function above.
      	// The only change is to add the 3rd paramater [async] which defaults to 'true'.
      	// When it is 'true', everything works fine, but when set to 'false', neither the onload() or onerror()
      	// functions are called. This code works with SDK 3.2.3, but not with SDK 3.3.0 or 3.4.0.
      	client.open("GET", url, false);
      	// Calling with async set to true succeeds 
      	//client.open("GET", url, true);
       
      	// Send the request.
      	client.send();
      

        Attachments

          Activity

            People

            • Assignee:
              hknoechel Hans Knöchel
              Reporter:
              paulking7 Paul R. King
              Reviewer:
              Chee Kiat Ng (Inactive)
              Tester:
              Abir Mukherjee
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-20368
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code