-
13 Mar 2012 2:04 AM #1
Unanswered: Ajax timeout sencha 2 and phonegap
Unanswered: Ajax timeout sencha 2 and phonegap
Hi every one,
I'm migrating an 1.1 sencha application packaged with phoneGap into sencha 2. I have some problems to reach with my REST web services when deployed on IOS simulator (and also in a real device).
Actually I always get a timeout when sending my request. I use the following piece of code :
Note that everything works fine in a web browser and in the 1.1 version.Code:Ext.Ajax.request({ url: 'http://mydomain.com/ws/service', method:'GET', timeout: 5000, success: function(response){ console.log('invocation succeeds'); console.log(response); }, failure: function(e){ console.log('invocation fails with error', e); }, })
This is the error object on the failure method.- aborted: undefined
- request: Object
- requestId: NaN
- status: 0
- statusText: "communication failure"
- timedout: true
- __proto__: Object
Thanks in advance for your help
Ben
-
13 Mar 2012 4:22 AM #2Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,582
- Vote Rating
- 433
- Answers
- 3102
Timeout of 5 seconds isn't that long.
Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
-
13 Mar 2012 4:38 AM #3
I've just figured out what happened. My WebService use http basic authentication and I use
Where buildBasicAuthParam encode login:password in base 64.Code:Ext.Ajax.defaultHeaders = { 'Authorization' : buildBasicAuthParam('myLogin, 'mypass') }
I watched http header with wireshark and nothing appeared in my request headers.
Instead I add headers directly in my request like this
And this seems to solve my issue.Code:Ext.Ajax.request({ url: 'http://mydomain.com/ws/service', method:'GET', timeout: 5000, headers : { "Authorization": buildBasicAuthParam('mylogin', 'myPassword') }, success: function(response){ console.log('invocation succeeds'); console.log(response); }, failure: function(e){ console.log('invocation fails with error', e); }, })
Maybe there is a bug in defaultHeaders implementation?


Reply With Quote