Error ASIHTTPRequest, Code 2, on the iPad itself

I have a program that asynchronously uploads 4 files to the Documents ipad folder, and it works fine on the simulator, but when I use it on the actual ipad, it gives me this error:

Error Domain=ASIHTTPRequestErrorDomain Code=2 "The request timed out" UserInfo=0x1c0810 {NSLocalizedDescription=The request timed out}

Is there a way to fix this or extend the time before the time runs out?

+4
source share
2 answers

The reason you get better results in the simulator is probably because the simulator uses the built-in network card, and the Mac network card is probably stronger than the one on the iPad.

You can use the following code to change the timeout interval. This code will set the timeout to twenty seconds:

[request setTimeOutSeconds:20]

According to the ASIHTTPRequest How to Use page , you can tell ASIHTTPRequest to retry N times, for example:

[request setNumberOfTimesToRetryOnTimeout:2];

EDIT:

Although this is 2016 and ASIHTTPRequest has long been out of date, there is another useful bit of information for diagnosing network problems on iOS devices. Try using the Network Link Conditioner. It comes with iOS and can be downloaded on macOS.

This article (link) from NSHipster contains excellent configuration information.

+7
source

This problem may be caused by the following. When we send httprequest and do not receive a response from the server, but at this time you send another httprequest and with the second response to the request before the first request.

0
source

All Articles