Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

XHR timeout when using 3G, fine via WiFi

Yes, I know that makes no sense. LOL

Since installing iOS 4 onto my 3GS my apps can only make XHR calls when the iPhone is connected via wifi. When the same app on the same phone is opened on a 3G connection, xhr.onerror is triggered and this is the message I see:

error = "Error Domain=ASIHTTPRequestErrorDomain Code=2\"The request timed out\" UserInfo=0x37d2e0 {NSLocalizedDescription=The request timed out}"; source=[object TiNetworkClient];

Any ideas? This has killed both of my published apps. Changing Ti SDK versions doesn't make any difference.

— asked June 22nd 2010 by Dan Giulvezan
  • 3g
  • ios
  • ios4
  • iphone
  • wifi
  • xhr
3 Comments
  • Seems it may be related to the iOS 4 installation. Found that nothing was working over 3G, going through a restore now to see if it makes a difference.

    — commented June 22nd 2010 by Dan Giulvezan
  • how did you collect that error message? just curious.

    — commented June 22nd 2010 by Caio Iglesias
  • Had something like this in my code after the xhr.onload

    xhr.onerror = function(e) {
    alert(e);
    };

    Then just typed what I saw here.

    — commented June 22nd 2010 by Dan Giulvezan

5 Answers

  • I know how to fix it. HttpClient triggers a false timeout on slower networks (yes it does!!!).
    I was getting the same error on the old slow iphone. There is something in the underlying class of the HttpClient, that the code which is supposed to fix the false timeout, doesnt work.

    The solution is remove the timeout at all, like this:

    xhr.setTimeout(0);

    Then it will work, although sometimes verrrrrry slooooowwwww

    — answered July 8th 2010 by Anna Kozynenko
    permalink
    0 Comments
  • It sounds like either a DNS lookup or an interface issue.
    Does the problem occur if you use the IP address or when you use the DNS name?

    — answered July 8th 2010 by David Ashwood
    permalink
    0 Comments
  • duplicate

    — answered June 22nd 2010 by Dan Giulvezan
    permalink
    0 Comments
  • Still trying to get things working again but it does look like this is result of an iOS 4 upgrade problem and nothing to do with Titanium.

    Here's some info in case anyone else runs into the same sort of thing:

    http://discussions.apple.com/thread.jspa?threadID=2469607&tstart=0

    — answered June 22nd 2010 by Dan Giulvezan
    permalink
    1 Comment
    • Cheers Dan, Deploying app onto device I've encountered this niggle (premature timeout) with iOS4/XHR on a 3GS iphone.

      — commented October 13th 2010 by Chris Reed
  • Hi, I had the same problem using 3g.
    What i did after trying for hours was to disable the 3g , using the edge and finally re-enable 3g.
    this worked for me still now. Hope can help.

    — answered July 8th 2010 by Andrea S
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.