【问题标题】:Disable connection pooling for WCF net.tcp bindings禁用 WCF net.tcp 绑定的连接池
【发布时间】:2012-03-15 05:25:08
【问题描述】:

我有一个特定的场景需要禁用 net.tcp 连接池。我意识到这不是一个理想的配置,但是我需要暂时这样做以解决我特定环境中的问题。

谁能提供一个禁用连接重用\池化的 net.tcp 绑定配置示例?

【问题讨论】:

    标签: wcf net.tcp


    【解决方案1】:

    这是我在代码中的做法。

    NetTcpBinding tbinding = new NetTcpBinding(SecurityMode.None, true);
    
    // set some stuff on the binding ...
    // ...
    
    BindingElementCollection bElementCol = tbinding.CreateBindingElements();
    
    TcpTransportBindingElement transport = bElementCol.Find<TcpTransportBindingElement>();
    transport.ConnectionPoolSettings.IdleTimeout = TimeSpan.Zero;
    transport.ConnectionPoolSettings.LeaseTimeout =  TimeSpan.Zero;
    transport.ConnectionPoolSettings.MaxOutboundConnectionsPerEndpoint = 0;
    
    CustomBinding customBinding = new CustomBinding();
    customBinding.Elements.AddRange(bElementCol.ToArray());
    customBinding.Name = "NetTcpBinding";
    // use customBinding instead of tbinding
    

    这里有一些对我有帮助的链接:

    How to set the leaseTimeout setting programmaticaly?

    http://plainoldstan.blogspot.ca/2007/09/nettcpbinding-to-custombinding.html

    http://msdn.microsoft.com/en-us/library/ms788984.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-13
      • 2016-05-07
      • 1970-01-01
      • 1970-01-01
      • 2012-09-04
      相关资源
      最近更新 更多