Abhinav
Abhinav

Reputation: 38162

NSURLConnection time out

I am sending a synchronous request and getting a error

NSData *aResponseData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&aResponse error:&anError];

Error Domain=NSURLErrorDomain Code=-1001 "The request timed out." UserInfo=0x6ede3d0

What could be the reason for this? What is the default timeout for NSURLConnection? Can I print this value?

Upvotes: 1

Views: 3282

Answers (2)

Girish Kolari
Girish Kolari

Reputation: 2515

I think the connection is getting timed out due to the server(since error is not consistent) ... I suggest handle this error and try to send the request again ..

do a retry for 2 or 3 times with a small delay -- should help you in great level ...

Upvotes: 0

csano
csano

Reputation: 13716

Have you checked to make sure you're able to connect to the URL in a browser or using a tool of some sort (e.g. curl or wget)? How about from Safari on the device (or simulator) you're testing on just to make sure it's not a network issue of some sort?

You can specify a timeout value by creating your NSURLConnection using the requestWithURL:cachePolicy:timeoutInterval: class method.

Upvotes: 2

Related Questions