Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

setting timeout for a long running WCF Service

Tags:

wcf

timeout

I have a WCF service method which takes more than two hours to execute (runs some reports). how can I make sure that it doesn't timeout regardless of the time it takes? I think there are many timeout settings in WCF config, I am not sure which one is relevant for me. for ASMX webservices, there was an option to specify infinite timeout setting, is there a similar one for WCF?. also do I need to alter any IIS settings for this (WCF servcie is hosted in IIS), like recycling of worker processes, idle timeouts etc?

like image 500
RKP Avatar asked Dec 09 '22 11:12

RKP


2 Answers

This is an abuse of web services. Don't do this.

Instead, have the web service kick off the long-running operation, running in a separate process. If the clients need to know when the reports are done, then have the "separate process" keep track of the report creation and have it note when the reports are finished. The client can call a web service to check that status.

You really don't want to be depending on an HTTP connection remaining open for hours. It's a network. Things happen on networks. Bad things.

like image 80
John Saunders Avatar answered Jan 14 '23 06:01

John Saunders


Have you considered using callbacks? Your client sends a request and then waits for a notification from the server for when it is done? This would probably require a change in the client, but in that way, your service can "rattle the chain" and tell the client when the report is finished.

help: http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx

WCF timeouts: http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/84551e45-19a2-4d0d-bcc0-516a4041943d/

You should also consider the timeouts on the client side, as well. (binding.OpenTimeout, ReceiveTimeout, CloseTimeout etc.)

Another option would be to host the WCF in a Windows Service, which could simplify your situation, as it removes IIS from the equation:

http://msdn.microsoft.com/en-us/library/ms733069.aspx

Or, what about using a one way WCF call? That way, the call will return to the client ASAP after sending the request.

Need sample fire and forget async call to WCF service

like image 28
Larsbj Avatar answered Jan 14 '23 08:01

Larsbj