Reputation: 113
Let say I have a webservice (WCF and ASMX .net framework 4.8) which is hosted on IIS 10. Webservice has a method with this content:
public CustomerListResponse Get(CustomerListRequest request)
{
//sleep for 1 hour
System.Threading.Thread.Sleep(TimeSpan.FromHours(1));
return new CustomerListResponse();
}
The line that is performing sleep on thread is just to show that there is code that in some cases can take long time.
What I'm looking is setting or way to limit allowed processing time for example to one minute and error returned to client. I want the processing be killed by IIS/WCF/ASMX if the execution time will exceed one minute.
Unfortunately I didn't found a way in IIS for that. Also I don't have access to client code to set this limit on other side - change is possible only on server side.
What I tried:
<httpRuntime targetFramework="4.8" executionTimeout="60" />
- also didn't workI don't have other ideas how to achieve that, but I believe there should be some solution to be able control how long we want to spend on processing.
Upvotes: 0
Views: 85
Reputation: 578
You need to set the timeout on both client-side and server-side.
Client-side:
SendTimeout is used to initialize OperationTimeout, which manages the entire interaction of sending a message (including receiving a reply message in a request-reply case). This timeout also applies when a reply message is sent from the CallbackContract method. OpenTimeout and CloseTimeout are used to open and close channels (when no explicit timeout value is passed). ReceiveTimeout not used.
Server-side:
Send, open, and close timeouts are the same as on the client side (for callbacks). ReceiveTimeout is used by the ServiceFramework layer to initialize idle session timeouts.
Upvotes: 0