NSURLConnection's sendSynchronousRequest enforces minimum 30 second timeout? NSURLConnection's sendSynchronousRequest enforces minimum 30 second timeout?

Posted by smokris on 2007.07.10 @ 16:47

Filed under:

While writing the new Image Downloader (Blocking) QC patch for CoreMelt, I ran into what appears to be a bug in Mac OS X’s NSURLConnection framework — if you construct an NSURLRequest and specify a timeout of less than 30 seconds, it’s ignored when you perform a [NSURLConnection sendSynchronousRequest:returningResponse:error:]. The request takes at least 30 seconds to time out, contrary to what the documentation suggests..

Steps to Reproduce:

  1. Construct an NSURL with an http-based url pointing to a server that is currently offline.
  2. Execute the following code block:
    NSURLRequest *request=[NSURLRequest
    NSData *data=[NSURLConnection
  3. Compare the timestamps of “begin” and “end”. though they should presumably differ by 5 seconds, they actually differ by exactly 30 seconds.

Any ideas?

Steve Mokris is a developer at Kosada, Inc.

On a somewhat related note, IOBluetooth inquiries have an application-configurable timeout that defaults to 10 seconds (the input is an unsigned char, so one would assume that it could inquire for up to 255 seconds). However, it appears to disregard this setting as well (on 10.5).

I am also facing the same issue. Previously when I was using iPhone SDK 2.1 my code was working fine but since when I have upgraded to 3.0 time out is not working its taking more than 30 secs. I my case I guess its 45 secs.

Let me know if you have come across any solution for this … or any alternative for the above functionality…

Thanks, Paresh Nawale