The NSURLRequest
class (iOS docs, OS X docs) in Cocoa has a timeoutInterval
property. The docs state
If during a connection attempt the request remains idle for longer than the timeout interval, the request is considered to have timed out.
What does 'idle' mean, here? As best as I can tell, what this means in practice is that if I set a 30 second timeoutInterval
and call a method that sends the NSURLRequest
, then if the body of the HTTP response hasn't returned 30 seconds after sending the request, the request times out. But is that really what's going on?
A few things I can think of that might trigger the idleness timer to reset: receiving the HTTP headers, or receiving part of the body. But which (if either) matters in reality?
No bytes received for 30 seconds would be the normal definition. You should be able to write a very simple HTTP server (there are sample projects all over) and run it on a private port, then connect to it to prove it to yourself.
To simulate timing out in your server, just add "40" or some constant to the byte you are promising the client, so the client will wait forever for 40 bytes extra bytes at the end that aren't ever coming.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With