Titanium JIRA Archive
Appcelerator Community (AC)

[AC-6490] Timeout property not working of T.Network.createHttpClient in iOS

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2020-02-14T15:27:35.000+0000
Affected Version/sAppcelerator Studio 4.3.0
Fix Version/sn/a
ComponentsTitanium SDK & CLI
Labelsn/a
Reportershishir.roy
AssigneeAbir Mukherjee
Created2020-02-13T13:34:37.000+0000
Updated2020-02-14T15:27:35.000+0000

Description

Hi, Tiimeout property and error event not working for request which is not proper in iOS platform. Example below:
var url = "https://www.google .com/";

// above url have space after keyword google

Ti.Network.createHTTPClient({
				onload: function(e)
				{
					Ti.API.info("Success");
				},
				onerror: function(e)
				{
					Ti.API.info("Error: " + e.error);
									
				},
				timeout: 60000
			});
			
			client.open("GET", url);			
			client.send(); 
Above code, when the request made from iOS platform with incorrect url then, not getting any success or error callback even and timeout also not working. Note: Same code working fine in Android and Windows app

Comments

  1. shishir.roy 2020-02-13

    IOS Version: 13.3 Titanium SDK: 8.2.1.GA
  2. Ewan Harris 2020-02-13

    [~shishir.roy] I don't think the behaviour you're seeing on Android is a timeout, it's being passed an invalid host so is immediately throwing that as an error Error: Invalid host: https://www.google%20.com/ and not waiting for the timeout. Using an api like httpbins delay shows that the timeout appears to be working as intended on iOS, calling https://httpbin.org/delay/10 will wait 10 seconds before responding, after making the request it will error due to my timeout property only being 1 second
       var win = Ti.UI.createWindow();
       win.addEventListener('click', () => {
       	var url = "https://httpbin.org/delay/10";
       	// above url have space after keyword google
       	var client = Ti.Network.createHTTPClient({
       		onload: function(e){ 
       			Ti.API.info("Success"); 
       		},
       		onerror: function(e) {
       			Ti.API.info("Error: " + e.error);
       		},
       		timeout: 1000
       	});
       	client.open("GET", url);
       	client.send();
       })
       win.open();
       
  3. shishir.roy 2020-02-13

    Yeah, agree with you. But why invalid url is not throwing any error in iOS. We have scenario if user is entered invalid url while the request to server then it is not throwing any error and also timeout is not happening. So please suggest how it will throw an error if it is invalid url.
  4. Rene Pot 2020-02-14

    [~shishir.roy] it looks like from my testing you should be able to check the connected property whether or not the call has succeeded. In my tests in the simulator, it looks like this boolean is updated immediately, but to be safe you can use a timeout to check this property. https://docs.appcelerator.com/platform/latest/#!/api/Titanium.Network.HTTPClient-property-connected
  5. Rene Pot 2020-02-14

    Considering this ticket is about Timeout, I've created a new ticket specifically for improving the error flow with invalid URL: TIMOB-27767 Therefore I'm closing this ticket, please watch that ticket to be updated on progress.

JSON Source