[AC-6490] Timeout property not working of T.Network.createHttpClient in iOS
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | n/a |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2020-02-14T15:27:35.000+0000 |
Affected Version/s | Appcelerator Studio 4.3.0 |
Fix Version/s | n/a |
Components | Titanium SDK & CLI |
Labels | n/a |
Reporter | shishir.roy |
Assignee | Abir Mukherjee |
Created | 2020-02-13T13:34:37.000+0000 |
Updated | 2020-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
IOS Version: 13.3 Titanium SDK: 8.2.1.GA
[~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, callinghttps://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 secondYeah, 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.
[~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-connectedConsidering 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.