Wcf TimeoutException

时间:2016-12-16 09:26:34

标签: c# wcf azure timeoutexception

我创建了使用Azure Cloud Service的WCF应用程序。 有时客户端捕获TimeoutException大约每天3次。 现在,客户端总数约为100个客户端。所以100个cleint同时访问wcf服务器。 设置如下。我如何优化?还是我错了?

  1. WorkerRols.cs

    ServicePointManager.DefaultConnectionLimit = Int32.MaxValue;
    var netTcpBinding = new NetTcpBinding();
    netTcpBinding.Security.Mode = SecurityMode.Transport;
    netTcpBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.None;
    netTcpBinding.MaxBufferPoolSize = 314572800;
    netTcpBinding.MaxReceivedMessageSize = 20971520;
    netTcpBinding.MaxBufferSize = 20971520;
    netTcpBinding.ListenBacklog = 2147483647;
    netTcpBinding.MaxConnections = 2147483647;
    netTcpBinding.ReceiveTimeout = new TimeSpan(0, 1, 0);
    //binding.SendTimeout = new TimeSpan(0, 3, 0);
    //binding.CloseTimeout = new TimeSpan(0, 3, 0);
    netTcpBinding.ReliableSession.Enabled = true;
    netTcpBinding.ReliableSession.InactivityTimeout = new TimeSpan(0, 1, 0);
    ServiceThrottlingBehavior throttle;
    throttle = host.Description.Behaviors.Find<ServiceThrottlingBehavior>();
    if (throttle == null)
    {
            LogWriter.PutInfo(CLASSNAME, "throttle == null");
            throttle = new ServiceThrottlingBehavior();
            throttle.MaxConcurrentCalls = Int32.MaxValue;
            throttle.MaxConcurrentSessions = Int32.MaxValue;
            throttle.MaxConcurrentInstances = Int32.MaxValue;
            host.Description.Behaviors.Add(throttle);
    }
    
  2. 的app.config

    <system.net>
            <connectionManagement>
                    <add address="*" maxconnection="65535"/>
            </connectionManagement>
    </system.net>
    

0 个答案:

没有答案