views:

86

answers:

2

Is there something in WCF configuration that defines a timeout for executing a request at service side? E.g. WCF service will stop executing request after some time period. I have a service which make some work depending on client input. In some cases a such call may take too much time. I want to limit the execution time of such requests on service side, not client one using SendTimeout. I know about OperationTimeout property, but it doesn't abort the service request, it just tells a client that the request is timed out.

+3  A: 

In general terms, there's nothing that will totally enforce this. Unfortunately, it's one of those things that the runtime can't really enforce nicely without possibly leaving state messed up (pretty much the only alternative for it would be to abort the running thread, and that has a bunch of undesirable consequences).

So, basically, if this is something you want to actively enforce, it's a lot better to design your service to deal with this so that your operation execution has safe interruption points where the operation can be terminated if the maximum execution time has been exceeded.

Though it's a lot more work, you'll likely be more satisfied with it in the long run.

tomasr
Looks like there is no other solution for now. Thanks
Kamarey
A: 

Have you tried setting the TransactionTimeout Property on the Service?

Example

  [ServiceBehavior(TransactionTimeout = "00:00:30")]

"TimeSpan object that represents the time within which transactions must complete or be automatically aborted" - MSDN

CkH
It didn't work for me. "or be automatically aborted" relates to transaction and not to currently running operation (service method call). So even if transaction is aborted, the operation will be finished. At least it worked so in my tests. Also this is not job of transactions to abort "too long calls", so use them in this case would be wrong, if possible. Anyway thanks for your answer.
Kamarey