Client-Side CommunicationException while Service works properly

前端 未结 5 2000
长发绾君心
长发绾君心 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:11

    HTTP protocol defines a limit of 2 connections to the same web server at the same...

    Since you are using http the behaviour you see might be related to that limit...

    There is a registry setting for this and a programatic way - you probably need to increase that limit on your client (depending on the quantity of threads you are using)...

    Other relevant settings (client-side) can be found here.

    0 讨论(0)
  • 2021-01-07 23:11

    I had the same problem. In my case it was my mistake. I closed the channelFactory (proxy) after starting threads.

    0 讨论(0)
  • 2021-01-07 23:14

    I'd suggest to verify 2 points:

    1. Throttling on the server, like

      behavior name="Throttled"
      serviceThrottling
      maxConcurrentCalls="1"
      maxConcurrentSessions="1"
      maxConcurrentInstances="1"

    2. Not closed WCF sessions - do you close all your sessions (client proxy) after used?
      In my case when I enlarged all timeouts to max, I got situation when after X calls, service became "stuck". When I changed timeouts, I was received exception like yours.

    It was several years ago, So i did not remember exactly. Also, I remember I found good article that was described how and why to change Service Instance mode to help this (sessions) issue.

    0 讨论(0)
  • 2021-01-07 23:16

    Ok, this is what happening - you have a faulty network card that is being overheated after few hours and when that happens it begins to short-circuit, as result your client side "thinks" that the server was shut down. End of story - 100% sure. where's my bounty?

    btw: it is overheated either cause of bad design especially if you are using laptop or due to a damage already exists in it.

    0 讨论(0)
  • 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++;
                }
    
    0 讨论(0)
提交回复
热议问题