1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    20
    Vote Rating
    3
    bstrappazzon is on a distinguished road

      0  

    Default 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 :

    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);
            },
        })
    Note that everything works fine in a web browser and in the 1.1 version.

    This is the error object on the failure method.
    • aborted: undefined
    • request: Object
    • requestId: NaN
    • status: 0
    • statusText: "communication failure"
    • timedout: true
    • __proto__: Object
    Is there something wrong in my code? or maybe something in sencha integration with phonegap?

    Thanks in advance for your help

    Ben

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,642
    Vote Rating
    900
    Answers
    3574
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Timeout of 5 seconds isn't that long.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    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 in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    20
    Vote Rating
    3
    bstrappazzon is on a distinguished road

      0  

    Post


    I've just figured out what happened. My WebService use http basic authentication and I use

    Code:
    Ext.Ajax.defaultHeaders = {    
        'Authorization' : buildBasicAuthParam('myLogin, 'mypass')
    }
    Where buildBasicAuthParam encode login:password in base 64.

    I watched http header with wireshark and nothing appeared in my request headers.

    Instead I add headers directly in my request like this

    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);        
             },    
    })
    And this seems to solve my issue.

    Maybe there is a bug in defaultHeaders implementation?

Thread Participants: 1

Tags for this Thread