WCF服务导致客户端回调被阻止时的延迟 [英] WCF service causing delays while a client callback is blocked

查看:90
本文介绍了WCF服务导致客户端回调被阻止时的延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的自托管WCF服务存在问题.服务已经稳定了一段时间,但是现在我们最近的一个客户给我们带来了很多TimeoutException问题.

I haveng an issue with my self-hosted WCF service. THe service has being somewhat stable for a while, but now one of our recent clients is causing us a lot of TimeoutException problems.

我们的服务使每个客户端的wcf对象实例化,如下所示:

Our service instatiates the wcf object per client as follows:

  [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,
    ConcurrencyMode = ConcurrencyMode.Multiple,UseSynchronizationContext = false,
    MaxItemsInObjectGraph = 65535000)]

 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession,
    ConcurrencyMode = ConcurrencyMode.Multiple, UseSynchronizationContext = false ,
    MaxItemsInObjectGraph = 65535000 )]

此外,我们已将服务的发送超时配置为30秒.客户端应用程序实例化的每个对象都有其自己的ICallback对象,以调用客户端中的操作.

Also, we have configured the send timeout of the service with 30 seconds. Each object instatiated by the client application has it's own ICallback object to call the operations in the client.

一个客户端阻塞它的行为正在发生,直到处理消息或触发TimeoutException为止.当回调被阻止时,所有其他客户端都停止实时接收其信息.

The behavior is happening while one client blocks it's call until the message is procesed or a TimeoutException is triggered. While the callback is blocked, all of the other clients stop receiving their information in realtime.

端点配置如下:

 

< netTcpBinding>
       < binding name ="TcpConfig"; closeTimeout ="00:01:00"; openTimeout =" 00:01:00"
                                    receiveTimeout ="00:01:30"; sendTimeout ="00:00:15" transactionFlow =假"
                                    transferMode =缓冲的". transactionProtocol ="OleTransactions"   hostNameComparisonMode =" StrongWildcard"
                                    listenBacklog ="500" maxBufferPoolSize ="524288" maxBufferSize ="524288"
                                    maxConnections ="500". maxReceivedMessageSize ="524288">
         < readerQuotas maxDepth ="0" maxStringContentLength ="0"; maxArrayLength ="131072"
               b maxBytesPerRead ="0"; maxNameTableCharCount ="0"/>
         < reliableSession enabled ="false"/>
         <安全模式=无">
           < transport clientCredentialType ="None" protectionLevel =无"/>
           < message clientCredentialType =无"/>
         </security>
       </binding>
     </netTcpBinding>

<netTcpBinding>
        <binding name="TcpConfig" closeTimeout="00:01:00" openTimeout="00:01:00"
                 receiveTimeout="00:01:30" sendTimeout="00:00:15" transactionFlow="false"
                 transferMode="Buffered" transactionProtocol="OleTransactions"    hostNameComparisonMode="StrongWildcard"
                 listenBacklog="500" maxBufferPoolSize="524288" maxBufferSize="524288"
                 maxConnections="500" maxReceivedMessageSize="524288">
          <readerQuotas maxDepth="0" maxStringContentLength="0" maxArrayLength="131072"
                        maxBytesPerRead="0" maxNameTableCharCount="0"/>
          <reliableSession enabled="false"/>
          <security mode="None">
            <transport clientCredentialType="None" protectionLevel="None"/>
            <message clientCredentialType="None"/>
          </security>
        </binding>
      </netTcpBinding>

 

并开始为:

m_Host =新的ServiceHost(typeof(FormService),新的Uri("net.tcp://localhost"));
          

           ServiceThrottling行为油门;
          节流= m_Host.Description.Behaviors.Find< ServiceThrottlingBehavior>();
          如果(油门==空)
           {
                            节流阀=新ServiceThrottlingBehavior();
                            节流阀.MaxConcurrentCalls = int.MaxValue;
                            节流阀.MaxConcurrentSessions = int.MaxValue;
                            节流阀.MaxConcurrentInstances = int.MaxValue;

                             m_Host.Description.Behaviors.Add(throttle);

                             System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;

           }

m_Host = new ServiceHost(typeof(FormService), new Uri("net.tcp://localhost"));
           

            ServiceThrottlingBehavior throttle;
            throttle = m_Host.Description.Behaviors.Find<ServiceThrottlingBehavior>();
            if (throttle == null)
            {
                throttle = new ServiceThrottlingBehavior();
                throttle.MaxConcurrentCalls = int.MaxValue;
                throttle.MaxConcurrentSessions = int.MaxValue;
                throttle.MaxConcurrentInstances = int.MaxValue;

                m_Host.Description.Behaviors.Add(throttle);

                System.Net.ServicePointManager.DefaultConnectionLimit = int.MaxValue;

            }

 

如何避免这种行为?

推荐答案

你好,

很显然,我们需要了解束缚了客户的因素.如果这是您可以按需复制的问题,那么我建议当阻塞发生时,我们收集该过程的两个用户转储.然后,您可以将您的userdump文件发送给我,我会很高兴的 看看他们.

Cearly we need to see what has tied up the client. If this is a problem that you can reproduce on demand, then I'd suggeste we collect two userdumps of the process when the blocking is happening. Then you can send me your userdump files and I'll be happy to have a look at them.

如果您对此方法感兴趣,请回复我.

If you are interested in this approach, please respond to me.

托尼


这篇关于WCF服务导致客户端回调被阻止时的延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆