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:
    NSLog(@"begin");
    NSURLRequest *request=[NSURLRequest
        requestWithURL:url
        cachePolicy:NSURLRequestReloadIgnoringCacheData
        timeoutInterval:5.0];
    NSData *data=[NSURLConnection
        sendSynchronousRequest:request
        returningResponse:&response
        error:&error];
    NSLog(@"end");
  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?

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

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <pre> <div> <span> <b> <i> <br> <table> <tr> <td> <th> <small> <sub> <tex> <equation> <equations> <s>
  • You can enable syntax highlighting of source code with the following tags: [code], [blockcode], [applescript], [bash], [c], [cpp], [css], [diff], [drupal5], [drupal6], [html4], [java], [javascript], [latex], [lisp], [lua], [m68k], [make], [mysql], [objc], [pascal], [perl], [php], [python], [ruby], [sql], [xml].
  • You may insert videos with [video:URL]
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Adds typographic refinements.
  • LaTex commands embedded in text will be interpreted and rendered. Additional information can be found at DruTex Documentation Pages
    • Allowed commands include: \atop \binom \cdot \cfrac \choose \frac \int \ln \over \sum \to
      Allowed environments include: align array equation equations gather matrix split
    • Provides different environments to create rendered images (especially maths).
    • Assists automatic numbering of tex, equation, and equations environments.

    More information about formatting options