HTTPClient returning a false timeout on 3G only.
Hi. I've got an app running on an iPhone. Works fine in the simulator. Upload it to my phone (3GS with 4.0.2) and after a post to an HTTP Client I get the following error:
error = "Error Domain=ASIHTTPRequestErrorDomain Code=2\"The request timed out\" UserInfo=0x37d2e0 {NSLocalizedDescription=The request timed out}"; source=[object TiNetworkClient];
NOTE: This only happens when my post includes an image taken with the camera. No image or an image from the Gallery is fine. image from the camera is fine in wi-fi mode.
Even more perplexing the photo is actually uploaded to the server correctly, so it appears this is a "false" timeout?
I have tried resizing the images (down to < 100kb), and I still get the error.
Any suggestions?
3 Answers
-
I found an undocumented setting, "enableKeepAlive" for createHTTPClient. Doing the following fixes the issue:
xhr = Titanium.Network.createHTTPClient({ enableKeepAlive:false });
The problem is with the server not sending a "100-Continue" header, which the ASIHTTPRequest used in Titanium is waiting for.
in native the solution will be:
ASIHTTPRequest *req = [ASIHTTPRequest requestWithURL:url];
req.shouldAttemptPersistentConnection = NO;But for titanium, the above statement works!
Harald Sakshaug
-
This is a common problem. ImageView also times out after a very short time. And there is no way to set the timeout longer.
-
Help! I am also having this issue. Tried so many things. Any solution?