0

I have installed latest RestSharp NuGet package version (106.3.1) on my C# solution and when I make a request that takes much longer than usual (most of my requests take little time), then the request never returns back to the caller. Although I am working to make this fully async, I am intrigued why this is happening. Please see below a small snipped of my source code.

// Private RestClient variable relative to my class.
private RestClient _client;


// Request made to another service inside my method
RestRequest restRequest = new RestRequest("api/abc/def", Method.POST);
restRequest.AddParameter("Authorization", $"Bearer {token}", ParameterType.HttpHeader);
restRequest.AddHeader("Accept", "application/json");
var serializeObject = JsonConvert.SerializeObject(requestOp);
restRequest.AddParameter("Application/Json", serializeObject, ParameterType.RequestBody);
var restResponse = this._client.Execute(restRequest);

Please notice that I am making at the moment one request at the time. There are no other requests happening in parallel whatsoever but only when the request takes a bit longer than usual, it simply does not return. No timeouts, nothing... Any idea what could this be?

EDIT: When I debug the code on the server side, it returns to the caller with a return this.Ok(requestOutput);However, the response never gets received by the caller.

user3587624
  • 1,427
  • 5
  • 29
  • 60
  • Is it your API it's calling? If so, step through the code there and see what's slowing it down. – Reinstate Monica Cellio Aug 20 '18 at 10:53
  • Sorry, I should have said that the API that gets called returns with an OK and the result. return this.Ok(requestOutput); I will update the post! – user3587624 Aug 20 '18 at 10:56
  • If debugging not helping, then try to watch the traffic via Wireshark. – akop Aug 20 '18 at 11:21
  • I looked into Fiddler and it returns the data but the client never gets it. The data returned is a simply and small object with strings, btw. – user3587624 Aug 20 '18 at 11:33
  • Is your RestClient inside of a ASP.NET-Application? Maybe your execution will be killed by ASP? (standard setting is 20min, termination of ASP is "heavy", it also kills running instances) – akop Aug 20 '18 at 11:48
  • Yeah, it is a ASP.NET Web API. Timeout has increased and the request takes around 7 minutes to execute but maybe it is related to that? – user3587624 Aug 20 '18 at 11:50
  • 1
    https://stackoverflow.com/questions/3829202/iis-request-timeout-on-long-asp-net-operation – akop Aug 20 '18 at 11:52
  • tried above link but didn't work either. My request never returns a timeout but still bumping the value doesn't make the trick – user3587624 Aug 20 '18 at 13:36

0 Answers0