{ "id": "63128", "key": "TIMOB-2496", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "11234", "name": "Release 1.6.0 M01", "archived": true, "released": true, "releaseDate": "2010-12-20" } ], "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2011-04-15T03:21:19.000+0000", "created": "2011-04-15T03:21:17.000+0000", "priority": { "name": "Low", "id": "4" }, "labels": [ "android", "defect", "httpclient", "release-1.6.0" ], "versions": [], "issuelinks": [], "assignee": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2017-03-02T19:28:34.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "{html}

Titanium.Network.HTTPClient.onload fired with a delay! We tested\nit with the on the Iphone and some android phones. It hasn't this\nproblem on the Iphone(Iphone fire it on 2 seconds). But on my\nSamsung Galaxy S With android 2.2 on wifi it takes 10 to 16\nseconds. On a HTC Wildfire with wifi or 3G network it takes between\n3 to 5 minutes and sometimes not fired or takes longer! This issue\nreported on a HTC Desire too. It seems this problem is on first run\nof the app or when we clear cache and data of the app.
\nAlso I found a same reported problems on the developer center:
\n\nhttp://developer.appcelerator.com/question/881/titaniumnetworkhttpc...

\n

I tested it by Titanium SDK 1.4.1 and 1.5 and I'm sure that the\nserver answer to this requests quickly (We use google servers with\nthe appengine) and that codes work fine on the Iphone.
\nWe use this codes:

\n

var SessionID = '';
\nTi.App.addEventListener('nAjax', function(e)
\n{

\n
\nvar xhr = Ti.Network.createHTTPClient();\n\nxhr.onerror = function(r) {\n    trace('nAjax.onerror('+e.error+'): ' + r.error);\n    if (e.error) {\n        Ti.App.fireEvent(e.error,{error:r.error, status:xhr.status});\n    }\n    if (e.complete) {\n        Ti.App.fireEvent(e.complete,{status:xhr.status});\n    }\n};\n\nxhr.onreadystatechange = function() {\n    trace('nAjax.onreadystatechange('+e.success+') xhr.readyState: ' + xhr.readyState);\n}\n\nxhr.onload = function() {\n    trace('nAjax.onload('+e.success+') xhr.status: ' + xhr.status);\n    if (e.success) {\n        cookie = xhr.getResponseHeader('Set-Cookie');\n        if (cookie){\n            if (cookie.indexOf('sessionid') > -1) {SessionID = cookie.substring(cookie.indexOf('sessionid')+10, cookie.indexOf(';'));}\n        }\n\n        Ti.App.fireEvent(e.success,{response:this.responseText, status:xhr.status});\n    }\n    if (e.complete) {\n        Ti.App.fireEvent(e.complete,{status:xhr.status});\n    }\n};\n\nxhr.setTimeout(30000);\nxhr.open(e.method, e.url, false);\nif (e.username){\n    Ti.API.info('xhr.setRequestHeader');\n    xhr.setRequestHeader('Authorization','Basic ' + Ti.Utils.base64encode(e.username+':'+e.password));\n}\nif (Titanium.Platform.osname == 'android'){\n    if (SessionID.length > 0) {xhr.setRequestHeader('Cookie',('sessionid=' + SessionID + ';'));}\n}\n//send the data\nxhr.send(e.data);\ntrace('nAjax.send');\n
\n

});

{html}", "attachment": [ { "id": "18156", "filename": "app.js", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:21:17.000+0000", "size": 1158, "mimeType": "application/x-javascript" } ], "flagged": false, "summary": "Android: Titanium.Network.HTTPClient.onload fired with a delay!", "creator": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "subtasks": [], "reporter": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "environment": null, "comment": { "comments": [ { "id": "128636", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

@Farsad can you put your sample code into a small project that\nreproduces the failure including a url we can hit to test with.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:21:17.000+0000", "updated": "2011-04-15T03:21:17.000+0000" }, { "id": "128637", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Hi Farsad,

\n

I am unable to replicate the delay on 1.5 using the 2.2 API's. I\nhave attached the contents of the app.js for the simple test I\nwrote trying to replicate the issue. I have also been unable to\nreproduce this behavior on the droid 2 (running 2.2 with and\nwithout wifi). I also made sure to clear the data and cache before\nrunning the test.

\n

Can you please provide a simple test project and url as Don\nmentioned? Thanks in advance.

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:21:18.000+0000", "updated": "2011-04-15T03:21:18.000+0000" }, { "id": "128638", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Attached app.js as promised in previous update.

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:21:18.000+0000", "updated": "2011-04-15T03:21:18.000+0000" }, { "id": "128639", "author": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Thanks for your responds.

\n

I can't replicate this issue on a sample test app! I try to find\nthe reason of this problem on our app. our app codes are same as\ncreated sample app but doesn't work correctly.

\n

this is a trace of my app for a request:

\n

5:33:8 trace: nAjax.send
\n5:33:8 trace: nAjax.onreadystatechange(AjaxSuccess1)\nxhr.readyState: 1
\n5:39:29 trace: nAjax.onreadystatechange(AjaxSuccess1)\nxhr.readyState: 2
\n5:39:29 trace: nAjax.onreadystatechange(AjaxSuccess1)\nxhr.readyState: 3
\n5:39:31 trace: nAjax.onreadystatechange(AjaxSuccess1)\nxhr.readyState: 4
\n5:39:31 trace: nAjax.onload(AjaxSuccess1) xhr.status: 200

\n

Maybe this trace shows that server didn't respond to the\nrequest. but we have a 30 seconds timeout and we didn't get onerror\ntrace or any message. and server responds to the requests for the\nsample test app or our app on iphone quickly.
\nAlso the reports on the server shows that got request at 5:33:41 in\nabout 35 second delay and responded to it after 446ms.

\n

I'm confused! I working to find codes that makes different\nbetween sample test app and our app!

{html}", "updateAuthor": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:21:18.000+0000", "updated": "2011-04-15T03:21:18.000+0000" }, { "id": "128640", "author": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "body": "{html}

Hi Farsad,

\n

If the trace above is generated from the app in question, then\nthe onload is being called with minimal delay once the request is\nactually sent. The delay issue seems to stem (in the above trace at\nleast) from a 21 second delay between the open state (1) and the\nsent state (2).

\n

What is the URL you are trying to hit? Were you able to\nreproduce the behavior on the device in question with a sample app\nusing the app.js I provided?

\n

Thanks.

{html}", "updateAuthor": { "name": "opiecyrus", "key": "opiecyrus", "displayName": "Opie Cyrus", "active": true, "timeZone": "America/Chicago" }, "created": "2011-04-15T03:21:18.000+0000", "updated": "2011-04-15T03:21:18.000+0000" }, { "id": "128641", "author": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

I found the problem!
\nI was put a loading animation on the registration and login buttons\nby a CSS3 animation in our app. It was a small gif picture that\nanimated by this CSS3 code:

\n

.loadingAnimation { / -webkit-animation-name: rotateThis;\n-webkit-animation-duration:.7s;\n-webkit-animation-iteration-count:infinite;\n-webkit-animation-timing-function:linear;/ }\n@-webkit-keyframes rotateThis { / from {-webkit-transform:\nrotate(0deg);} to {-webkit-transform: rotate(360deg);}/ }

\n

I removed this and the problem solved! maybe it was a hug\nprocess for some android phones!

\n

Special thanks for your supports.
\nPlease close this topic and ban me! ;)

{html}", "updateAuthor": { "name": "farsad", "key": "farsad", "displayName": "Farsad", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:21:19.000+0000", "updated": "2011-04-15T03:21:19.000+0000" }, { "id": "128642", "author": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "body": "{html}

Closing as invalid per the submitters request.

{html}", "updateAuthor": { "name": "dthorp", "key": "dthorp", "displayName": "Don Thorp", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2011-04-15T03:21:19.000+0000", "updated": "2011-04-15T03:21:19.000+0000" }, { "id": "408468", "author": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "body": "Closed as invalid.", "updateAuthor": { "name": "lmorris", "key": "lmorris", "displayName": "Lee Morris", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2017-03-02T19:28:34.000+0000", "updated": "2017-03-02T19:28:34.000+0000" } ], "maxResults": 8, "total": 8, "startAt": 0 } } }