Client-Side CommunicationException while Service works properly

前端 未结 5 2019
长发绾君心
长发绾君心 2021-01-07 23:04

Currently i am facing a problem i do not understand. I have an wcf client that calls a wcf service through several threads at the same time (both on the same machine). Somet

5条回答
  •  耶瑟儿~
    2021-01-07 23:29

    Try to enable tracing at WCF side, you would get detailed information as to what is happening at server side.

    Also sometimes WCF channel factory is closed abruptly when client sending big number of requests. we faced similar issue when we have used certificate authentication with WCF. In that we have deviced RetryPolicy around this transient error. if we get this error, we abort channel factory, recreate and send again rather than throwing exception.

     while (retryCount <= MAXRETRY)
                {
                    try
                    {
                        return _proxyService.GetData(); // _proxyService is WCF proxy class
                    }
                    catch (CommunicationException transientException)
                    {
                         if (SLEEPINTERVAL> 0)
                        {
                            Thread.Sleep(SLEEPINTERVAL);
                        }
                        ((IClientChannel) _proxyService).Abort();
                        _proxyService = functionToCreateProxy();
                    }
    
                    retryCount++;
                }
    

提交回复
热议问题