Timeout on Async not working

1,270 views
Skip to first unread message

ayoung

unread,
Mar 2, 2011, 1:06:43 AM3/2/11
to RestSharp
I'm setting a timeout on the RestClient but it does not seem to be
timeout out. Rather it waits indefinitely. Do you see anything wrong
with this code? I checked the RestSharp codebase and it seems that
Timeout is being sent down the stack just fine. So I'm kind of at a
loss here.

protected void ExecuteAsync<T>(RestRequest request,
Action<RestResponse<T>> callback) where T : new()
{
var client = new RestClient();
client.Timeout = 10;
client.BaseUrl = DataConfiguration.HostingBaseUrl;
client.ExecuteAsync<T> (request, callback);
}

John Sheehan

unread,
Mar 2, 2011, 3:28:19 AM3/2/11
to rest...@googlegroups.com
"The Timeout property has no effect on asynchronous requests made with the BeginGetResponse or BeginGetRequestStream method...In the case of asynchronous requests, the client application implements its own time-out mechanism. Refer to the example in the BeginGetResponse method."


SIGH. HttpWebRequest screws us over again. Anyone want to implement the mechanism described here: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse.aspx

Andrew Young

unread,
Mar 2, 2011, 3:24:48 PM3/2/11
to rest...@googlegroups.com
Done.

John Sheehan

unread,
Mar 2, 2011, 7:08:45 PM3/2/11
to rest...@googlegroups.com
Nice! I'll try to review tonight.

David Poulin

unread,
Mar 10, 2011, 4:52:48 AM3/10/11
to rest...@googlegroups.com, John Sheehan
Is that ok right now concerning Aysnchronous request and timeout ? (I tried to get latest sources and have a check but could not find it).

2011/3/3 John Sheehan <johns...@gmail.com>

Andrew Young

unread,
Mar 10, 2011, 11:50:57 AM3/10/11
to rest...@googlegroups.com
David, this feature hasn't been merged into the master branch yet. https://github.com/johnsheehan/RestSharp/pull/114/commits

John Sheehan

unread,
Mar 10, 2011, 3:22:43 PM3/10/11
to rest...@googlegroups.com
sorry i'm running behind guys. i'll try to get to it soon, but it's
sxsw time and it's very busy.

Andrew Young

unread,
Mar 11, 2011, 4:19:10 PM3/11/11
to rest...@googlegroups.com
So it seems like I got BeginGetResponse to time out properly. But BeginGetRequestStream is not. The code is implemented pretty much exactly the same in either case. Not sure what the deal is.

Anyone got a clue?

See pull commit #114 for the changes.
Reply all
Reply to author
Forward
0 new messages