request timeout management

1,202 views
Skip to first unread message

Álvaro Monteiro

unread,
Apr 2, 2011, 9:37:19 PM4/2/11
to res...@googlegroups.com
Hi!!!

When the webserver i try to connect is down it takes a long time to
get a timeout response.
Is it possible to decrease this time? Does Restkit try several times
before warning me that there was a timeout? -> hence the long time it
takes..

Regards,

Alvaro Monteiro

David Carrico

unread,
Apr 2, 2011, 9:52:50 PM4/2/11
to res...@googlegroups.com
Just a guess but in the RestKit source, you could change:

static const NSTimeInterval kTimeout = 300.0;

to something shorter (in seconds), then rebuild the kit...


I'm not sure if that is the correct timeout though.


2011/4/2 Álvaro Monteiro <alvarosil...@gmail.com>

Blake Watters

unread,
Apr 3, 2011, 4:53:04 PM4/3/11
to res...@googlegroups.com, David Carrico
That timeout isn't actually connected -- I've thrown a TODO item into Pivotal to implement a configurable timeout. 
Blake Watters
Two Toasters | CTO

Álvaro Monteiro

unread,
Apr 4, 2011, 9:05:07 AM4/4/11
to res...@googlegroups.com, Blake Watters, David Carrico
Thank you Blake!

Just one more thing: Does Restkit try several times

before warning me that there was a timeout?
If so, i think it's safe to assume that if there is a timeout it happens because something went really wrong instead of some temporary loss of connectivity.
Is this true?

Gregory Combs

unread,
Apr 4, 2011, 6:57:13 PM4/4/11
to res...@googlegroups.com
Ironic, I just ran into this today. Hoping I can find the spot to hardcode a more reasonable timeout in the interim, I'm hoping to ship early this week.

Álvaro Monteiro

unread,
Apr 5, 2011, 5:55:28 AM4/5/11
to res...@googlegroups.com, Gregory Combs
If you can please share you solution. thks!!!

Blake Watters

unread,
Apr 5, 2011, 8:00:19 AM4/5/11
to res...@googlegroups.com, Gregory Combs
Greg -

If you want to implement a patch for this I'll merge it. Here's what you should do:
- Put a timeout property on RKRequest with a reasonable default interval
- At send time, fire an NSTimer that is set to go off on the interval
- When the NSURLConnection starts loading data (didReceiveData: or something), invalidate the timer
- When the timer goes off, cancel the request and either invoke didFailWithError: or we can add a new didTimeout: methose (I think I already did this on background requests branch, which needs to be merged when I get a minute)

- Blake


On Mon, Apr 4, 2011 at 6:57 PM, Gregory Combs <gco...@gmail.com> wrote:
Ironic, I just ran into this today. Hoping I can find the spot to hardcode a more reasonable timeout in the interim, I'm hoping to ship early this week.

Blake Watters

unread,
Apr 5, 2011, 8:01:17 AM4/5/11
to res...@googlegroups.com, Gregory Combs
BTW my research shows that NSURLConnection's default timeout is insanely high to allow the network time to connect and you can't override it easily, so you need to use a timer based solution as outlined

Álvaro Monteiro

unread,
Apr 5, 2011, 1:11:30 PM4/5/11
to res...@googlegroups.com, Blake Watters, Gregory Combs
ok thks guys.

peetonn

unread,
Oct 8, 2011, 9:48:04 AM10/8/11
to res...@googlegroups.com, Gregory Combs
i think not less important thing here is, in case invoking "didTimeout" - to remove timed out request from a queue. otherwise queue will contain these requests, won't it?

Sendhil P

unread,
Nov 9, 2011, 6:53:43 PM11/9/11
to res...@googlegroups.com, Gregory Combs
Did this ever make it in as a patch?

Blake Watters

unread,
Nov 9, 2011, 10:18:33 PM11/9/11
to res...@googlegroups.com
I have not merged such support

Kamil

unread,
Nov 29, 2011, 6:56:16 AM11/29/11
to res...@googlegroups.com
Ok, so what does the [someQueue setRequestTimeout:3] do in that case? Because I see no change. Timeout always defaults to Apple's 60 seconds. Is this also not connected?

Brian Morton

unread,
Jan 5, 2012, 5:38:57 AM1/5/12
to RestKit
I've forked and implemented this as prescribed in this thread. I've
opened a pull request (https://github.com/RestKit/RestKit/pull/491)
and hopefully I'm on the right track. Like I mention in the pull
request, I'm dying to spec what I've added, but I'm a bit lost as to
where to start. Any pointers that could push me in the right
direction would be greatly appreciated.

On Nov 9 2011, 7:18 pm, Blake Watters <blakewatt...@gmail.com> wrote:

Blake Watters

unread,
Jan 9, 2012, 8:35:38 PM1/9/12
to res...@googlegroups.com
Brian -

This patch looks very nice. I've added some comments on the pull request that should help you knock out some unit test coverage for the patch.
--
To stay sane & productive, I don't live in e-mail. If you need to reach me quickly, try this link: https://awayfind.com/blakewatters

Brian Morton

unread,
Jan 12, 2012, 2:23:58 AM1/12/12
to RestKit
I've added tests for making sure the RKRequest can timeout when the
server doesn't respond before the timeoutInterval as well as
confirming that an RKClient passes through its timeoutInterval to a
request that it creates. I've also added a route in the sinatra spec
server for triggering the timeout.

I was seeing some issues with the ruby process holding too long and
triggering the response loader timeout on the tests following it, but
i've shortened the times a bit and haven't been able to trigger that
issue again, so it should be good to go!

Thanks for the helpful hints and let me know if i missed anything.

-b

On Jan 9, 5:35 pm, Blake Watters <blakewatt...@gmail.com> wrote:
> Brian -
>
> This patch looks very nice. I've added some comments on the pull request
> that should help you knock out some unit test coverage for the patch.
>
Reply all
Reply to author
Forward
0 new messages