WCF service behaviour on Timeout exception
We have a WCF service method (synchronous), which calls another process (through COM) to do some stuff. Now this COM process takes about 10-15 seconds to complete and then returns the call to my service which in turn should be returned to the client.
On the WCF client side, we have a sendtimeout s开发者_如何学Pythonet as 5 seconds, so after 5 seconds we receive timeout exception in the client.
Now my question is what happens on the service side after the client receives timeout exception. Because the call the COM process is still in progress and may return to service after another 5-10 seconds, how the service handles this scenario.
Let me know if further input is required.
Regards,
Afaik, an exception is thrown on the client side but the service carries on the operation. If you have long running operations, you might check out asynchronous calls.
Update: If this is not possible and increasing the timeout is not an option by the same reason, I can't see how you can avoid the timeout exception. Some ways to recover:
If you'd like to abort the server operation on client timeout, you might add a service operation like
CancelCOMCall
, and invoke from the client when it catches aTimeoutException
, which would kill the COM process.If you want to let the operation complete but prevent duplicate calls from the client (caused by retries after timeout exception), you might save which COM operations are running per client and discard calls for already running processes.
I'd agree neither method is very neat, but it looks a little difficult to me without asynchronous calls. I'm not a WCF expert though.
精彩评论