KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm attempting to extend this answer on SO to make a WCF client retry on transient network failures and handle other situations that require a retry such as authentication expiration. Question: What are the WCF exceptions that need to be handled, and what is the correct way to handle them? Here are a few sample techniques that I'm hoping to see instead of or in addition to proxy.abort() : Delay X seconds prior to retry Close and recreate a New() WCF client. Dispose the old one. Don't retry and rethrow this error Retry N times, then throw Since it's unlikely one person knows all the exceptions or ways to resolve them, do share what you know. I'll aggregate the answers and approaches in the code sample below. // USAGE SAMPLE //int newOrderId = 0; // need a value for definite assignment //Service<IOrderService>.Use(orderService=> //{ // newOrderId = orderService.PlaceOrder(request); //} /// <summary> /// A safe WCF Proxy suitable when sessionmode=false /// </summary> /// <param name="codeBlock"></param> public static void Use(UseServiceDelegateVoid<T> codeBlock) { IClientChannel proxy = (IClientChannel)_channelFactory.CreateChannel(); bool success = false; try { codeBlock((T)proxy); proxy.Close(); success = true; } catch (CommunicationObjectAbortedException e) { // Object should be discarded if this is reached. // Debugging discovered the following exception here: // "Connection
Tags (comma-separated)
Save Edits
Cancel